✓ 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
shall I use serverscriptservice instead or use the GUI's?
No, the code above should work just fine
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!
Oh thanks! I fix that right away