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

How to get a player from a surface gui click?

Asked by 4 years ago

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
0
Wait, you need it so when you press the button it teleport s a player to you? Mrmonkeyman120 65 — 4y
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 Pooglies 7 — 4y

1 answer

Log in to vote
1
Answered by
Prestory 1395 Moderation Voter
4 years ago

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)
0
this isnt a gui in startergui this is a gui inside a part in workspace Gameplayer365247v2 1055 — 4y
0
Put I want the script to be server sided. Pooglies 7 — 4y
0
Your reply's are horrible you don't even understand what i have said read it more carefully Prestory 1395 — 4y
Ad

Answer this question