I made a local script in Startergui and it’s supposed to play each of the sounds for the events that occur. but for some reason script doesnt work:
local SelectSound = script.SelectSound
local HoverSound = script.HoverSound
local StarterGui = game:GetService("StarterGui")
--Buttons SFX
for _, v in pairs(StarterGui:GetDescendants()) do
if v:IsA("TextButton") or v:IsA("ImageButton") then
v.MouseEnter:Connect(function()
HoverSound:Play()
end)
v.MouseButton1Click:Connect(function()
SelectSound:Play()
end)
end
end
local SelectSound = script.SelectSound
local HoverSound = script.HoverSound
local ScreenGui = script:FindFirstAncestorOfClass("ScreenGui")
--Buttons SFX
for _, v in pairs(ScreenGui:GetDescendants()) do
if v:IsA("TextButton") or v:IsA("ImageButton") then
v.MouseEnter:Connect(function()
HoverSound:Play()
end)
v.MouseButton1Click:Connect(function()
SelectSound:Play()
end)
end
end
This will work providing the script is placed somewhere inside the “ScreenGui” instance itself, this is likely what you’re trying to achieve as opposed to dynamically modifying the “PlayerGui” of each “Player” instance.