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

How do I localize who clicked a TextButton?

I need help! Is there any way to do this? I've tried several ways but I've failed and I need help ASAP. Btw - This is a normal script on a SurfaceGUI > TxtButton > Script

1 answer

✓ Accepted answer

Since there's no easier way to find the player when they click on a SurfaceGui, you need a LocalScript in StarterPack or StarterGui. Here's an example:

local gui = game.Workspace.Part.SurfaceGui.TextButton

gui.MouseButton1Click:connect(function()
--code here
end)

Just remember to put in the correct things to define "gui."

4 comments

0

Thanks, I hadn't thought of something so simple becuase of putting my expectations up high! XD Thanks alot

0

No problem!

0

An easier way would probably be to put the SurfaceGui in PlayerGui then just setting the Adornee property. That way you can just use script.Parent.

0

@Perci You could do that but the SurfaceGui would be local. Say if you wanted to make a message on the SurfaceGui pop up when someone clicks it saying something like, "Player clicked the button" you'd have to replicate it to all the players. With this script, you only need to set the message once and everyone will be able to see it.

This discussion is preserved as it was. New answers, comments, and votes are closed.