Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I localize who clicked a TextButton?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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."

0
Thanks, I hadn't thought of something so simple becuase of putting my expectations up high! XD Thanks alot PlatinumLocks 50 — 9y
0
No problem! bobafett3544 198 — 9y
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. Perci1 4988 — 9y
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. Spongocardo 1991 — 9y
Ad

Answer this question