TextButton not working?

I’m working on a timer and i was preparing the model for it, but for some reason the button never worked. So I tried to make another button just to make sure im not making a mistake, and the button doesnt work. Heres the code:

local button = script.Parent.SurfaceGui.TextButton
print("works")

button.Activated:Connect(function()
	print("works")
end)

image_2024-10-29_122112183

Have you tried the LeftMouseClick thingy instead of ‘Activated’? Sadly I can’t make an example for you at the moment, but this might do the trick

By the way, use a LocalScript instead of a normal one

2 Likes

a fairly reminder that surface gui in parts do NOT connect events that are made for client, you will have to put it in StarterGui and set the adornee to the part desired.

1 Like

im dumb lol thanks for the solution

Please use the following script. Note that this should be a LocalScript instead of a ServerScript. Additionally, remember that SurfaceGuis are not the same as ScreenGuis; SurfaceGuis are meant for parts, while ScreenGuis are for the player’s screen.

Here is the fixed script you should use:

local button = script.Parent.SurfaceGui.TextButton
print("works")

button.MouseButton1Click:Connect(function()
    print("works")
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.