audio
This commit is contained in:
1 parent
5c91f5f61d
commit
d0f85a5fa8
3 files changed
+31
No files matched your search
@@ -0,0 +1,29 @@
|
||||
--!strict
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Sounds = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript)
|
||||
|
||||
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
|
||||
local bound: {[GuiButton]: boolean} = setmetatable({}, {__mode = "k"})
|
||||
|
||||
local function bindButton(instance: Instance)
|
||||
if not instance:IsA("GuiButton") or bound[instance] then return end
|
||||
local button = instance
|
||||
bound[button] = true
|
||||
|
||||
button.MouseEnter:Connect(function()
|
||||
if button.Active and button.Interactable and button:IsDescendantOf(playerGui) then
|
||||
Sounds.sound("ButtonHover")
|
||||
end
|
||||
end)
|
||||
button.Activated:Connect(function()
|
||||
if button:IsDescendantOf(playerGui) then
|
||||
Sounds.sound("ButtonPress")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
playerGui.DescendantAdded:Connect(bindButton)
|
||||
for _, instance in playerGui:GetDescendants() do
|
||||
bindButton(instance)
|
||||
end
|
||||
Reference in new issue
Block a user