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

Surface Gui button script not working? No ouput error?

script.Parent.MouseButton1Click:Connect(function()
	print("Test")
	script.Parent.Sound:Play()
end)

5 comments

0

What do you mean by "No ouput error?"

0

I dont get anything in my output but it does not work

0

Make sure that the script is a local script and its parent is the TextButton.

0

I mean make sure it is a normal script. My bad!

0

Oh i always tought it should be a localscript MB

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.