script.Parent.MouseButton1Click:Connect(function()
print("Test")
script.Parent.Sound:Play()
end)
✓ ANSWER ACCEPTED
Surface Gui button script not working? No ouput error?
1 answer
✓ Accepted answer
Put the SurfaceGui in StarterGui and set the Adornee to the part you want that show the SurfaceGui
After that use a LocalScript and put the script with the sound and the TextButton in the SurfaceGui.
--< Services
local PlayerService = game:GetService('Players') -- This is the folder you can see on the explorer.
--< Variables
local Player = PlayerService.LocalPlayer -- LocalScript only. This is you
local PlayerGui = Player:WaitForChild('PlayerGui')
local SurfaceGui = PlayerGui:WaitForChild('SurfaceGui')
local Sound = SurfaceGui:WaitForChild('Sound')
local TextButton = SurfaceGui:WaitForChild('TextButton')
--< Events
TextButton.MouseButton1Click:Connect(function()
Sound:Play()
end)
Hope this help, to more questions put it bellow in the commentaries
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
What do you mean by "No ouput error?"
I dont get anything in my output but it does not work
Make sure that the script is a local script and its parent is the TextButton.
I mean make sure it is a normal script. My bad!
Oh i always tought it should be a localscript MB