Weird Surface GUI TextButton Bug

I’ve been stuck on this for a while now and I can’t figure this out. I have a simple surface GUI (parented to the adorne in workspace)with a text button and a server script inside of it. The code is as simple as:

task.wait(5)
script.Parent.Activated:Connect(function()
	print("CLICKED FROM SERVER") -- only prints when I run from server
end)
script.Parent.MouseEnter:Connect(function()
	print("HOVERED FROM SERVER") -- prints
end)

And a client script too,

task.wait(5)
workspace:WaitForChild("UpgradesBillboard").SurfaceGui.TextButton.Activated:Connect(function()
	print("CLICKED FROM CLIENT") -- doesn't print
end)
workspace:WaitForChild("UpgradesBillboard").SurfaceGui.TextButton.MouseEnter:Connect(function()
	print("HOVERED FROM CLIENT") -- Prints
end)

However the client mouse button1 click does not print? I then tried and pasting the exact same model, with the surface gui and script etc, into another studio project and it worked. same hierarchy same code, but it didn’t work in the original project. I have a feeling its got something todo with the client getting messed up somewhere in the original game. Any ideas? Thanks!

Picture of surface gui
Screenshot 2024-04-21 104648

workspace:WaitForChild("UpgradesBillboard").SurfaceGui.TextButton.Activated:Connect(function()
	print("CLICKED FROM CLIENT") -- doesn't print

Instead of using “.Activated” use this instead:

workspace:WaitForChild("UpgradesBillboard").SurfaceGui.TextButton.MouseButton1Click:Connect(function()
	print("CLICKED FROM CLIENT") -- doesn't print

This still isn’t working.
Current code:

task.wait(5)
workspace:WaitForChild("UpgradesBillboard").SurfaceGui.TextButton.MouseButton1Click:Connect(function()
	print("CLICKED FROM CLIENT")
end)
workspace:WaitForChild("UpgradesBillboard").SurfaceGui.TextButton.MouseEnter:Connect(function()
	print("HOVERED FROM CLIENT")
end)

Output when im clicking is
Screenshot 2024-04-21 105352

Put the client sided script in starterplayerscripts please and retry

It already was.
Screenshot 2024-04-21 105803

There’s no other way than to do it on the client side and communicate with the server via a remote event or function

I just tried and it should work I don’t understand why it doesn’t work to you

workspace.Part.SurfaceGui.TextButton.MouseButton1Click:Connect(function()
	print("123123")
end)

It’s a client script in starterplayerscripts
image

Yeah, like I said I did the exact same thing in a different studio file and it worked, it just doesn’t work in this project file. I have no clue why. Everything is the same.

Try to remove the task.wait I don’t know what to think by now

Reset your studio maybe it’ll solve it.

Just restarted my PC, and still getting the same result. I think somethings just up with this particular file.

Are you sure there isn’t a different script possibly interfering. You also said this worked in a different program. That makes my think, reset the studio by restarting.

It turned out I had to move the surface gui to startergui, and set alwaysontop to true.

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