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

How to make a textbutton return a player?

Asked by
traigla 75
8 years ago

I understand that if you click a brick with the function

script.Parent.ClickDetector:connect(function(p)
    player = p.Parent
end)

But how would I get player in a textbutton on a surfacegui? I can't work it out. Thanks.

1 answer

Log in to vote
1
Answered by 8 years ago

For a surface gui it would have to be a local script put in starterpack/startergui. So we will be able to use localplayer. Example:

local textbutton = workspace.Part.SurfaceGui.TextButton

textbutton.MouseButton1Click:connect(function()
    print(game.Players.LocalPlayer)
    plr = game.Players.LocalPlayer
end)

That should work, hope it helped!

0
No, because the script is inside the surfacegui. traigla 75 — 8y
1
What do you mean the script is inside the surfacegui, when the button is clicked, you can get the localplayer from the local script that you put in starterpack/startergui, and if you need that player in a serverscript, then you can use RemoteEvents... that's the only way it's possible. AbsoluteAxiom 175 — 8y
0
The script is inside the surfacegui. What's so confusing about that? And I don't want the script in StarterPack/GUI. It needs to be in that part for that model. traigla 75 — 8y
0
Invite me to a party on roblox, so I can better explain... AbsoluteAxiom 175 — 8y
View all comments (4 more)
0
@Traigla, this is the only way you can get it, and if you want to do anything with the script that is going to be under the brick, that would be a server script, and you can send information to that from the local script using a RemoteEvent, abs is totally right. Scriptree 125 — 8y
0
You need to adornee the surface GUI to the actual part, but keep the real Gui inside the player DigitalVeer 1473 — 8y
0
I think triagla is pointing out that the local script is under the brick or surfacegui, and it isn't getting put into the player in game.Players dragonkeeper467 453 — 8y
0
Thats why you have to do what I said earlier, @dragon DigitalVeer 1473 — 8y
Ad

Answer this question