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

Get player from TextButon? ( Easy )

Asked by
14dark14 167
4 years ago

This is not a LocalScript! I used SurfaceGuion a part and added a text button. I thought getting the player from the character was going to be easy, but it turns out it doesn't work as ClickDetector does.

script.Parent.MouseButton1Click:Connect(function()
              --how do you get the player from this?
end)

usually what I do is this,

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    game:GetService("Players"):GetPlayerFromCharacter(player)
end)

but in this case, it just printed nil

0
There is not an current way without a localscript. moo1210 587 — 4y
0
There is, the player is already the parameter, you don't have to get the player from the character, the player is the parameter. killerbrenden 1537 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You have to add the SurfaceGui to their PlayerGui, then change the script to a local script

0
Can you read the whole post before answering 14dark14 167 — 4y
0
I don't need to find the player from ClickDetector, but from TextButton 14dark14 167 — 4y
0
oh my bad, let me look into it, i haven't done that yet so i need to experiment a bit jediplocoon 877 — 4y
0
Okay 14dark14 167 — 4y
View all comments (2 more)
0
here is a question someone previously asked that should solve your problem https://scriptinghelpers.org/questions/4926/how-do-i-get-the-user-who-clicked-a-surfacegui jediplocoon 877 — 4y
0
Put the surfacegui in startergui and create a localscript in the textbutton. Hydrogyn 155 — 4y
Ad

Answer this question