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

How to get a player from a surface gui click?

I have a part in the workspace and then a surface gui in that part, and in that surface gui a frame, and in that frame a button, I have this script going so far but dont know how to get the player using this server sided script?

script.Parent.MouseButton1Click:connect(function()
local player = game.Players.LocalPlayer

2 comments

0

Wait, you need it so when you press the button it teleport s a player to you?

0

No, I need it so when you press the button, it gives the player a hat, I have that script sorted, I just need to get the player from the click

1 answer

✓ Accepted answer

You should insert a local script in StarterGui which is the more efficient way to do this and inside the local script you can place this code

workspace.CustomizationGuiPart.SurfaceGui.Hats.Afro.MouseButton1Click:Connect(function()

local Player = game.Players.LocalPlayer -- player

print(Player.Name)

end)

3 comments

0

this isnt a gui in startergui this is a gui inside a part in workspace

0

Put I want the script to be server sided.

0

Your reply's are horrible you don't even understand what i have said read it more carefully

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