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

Get player from TextButon? ( Easy )

This is not a LocalScript! I used SurfaceGui on 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

2 comments

0

There is not an current way without a localscript.

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.

1 answer

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

6 comments

0

Can you read the whole post before answering

0

I don't need to find the player from ClickDetector, but from TextButton

0

oh my bad, let me look into it, i haven't done that yet so i need to experiment a bit

0

Okay

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

0

Put the surfacegui in startergui and create a localscript in the textbutton.

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