Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why will my sound not play when I hover my mouse?

When I hover my mouse over the button that I've created it will not play the sound effect??

Please help me!


script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = false
end)

script.Parent.MouseEnter:Connect(function()
	script.Sound:Play()
end)

1 answer

✓ Accepted answer

StarterGui acts a container for GUIs, it does not actually represent the authentic household origin of where the active User Interfaces are properly stored.

Upon connection, these GUIs get replicated over to the PlayerGui, to operate with the desired UI, you must always reference it through the authentic location.

local player = game:GetService("Players").LocalPlayer
local playergui = player:WaitForChild("PlayerGui")

local textbutton = script.Parent
local frame = playergui.ScreenGui.Frame

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = false
end)

script.Parent.MouseEnter:Connect(function()
	script.Sound:Play()
end)

4 comments

0

shall I use serverscriptservice instead or use the GUI's?

0

No, the code above should work just fine

0

Thanks so much! I used ur code and it did not work but than I saw that you used LocalPlayer, it should have been a local script. Thanks for the reply! Also you made a typo on line 5!

0

Oh thanks! I fix that right away

This discussion is preserved as it was. New answers, comments, and votes are closed.