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

Surface GUI in Workspace won't get the Player That Clicked it?

I have a surface GUI in workspace, it's a shop and it has a buy button in it. When the buy button is clicked I want it to fireserver to purchase the weapon for the player. When it's clicked it can't get the player that clicked it though. Any help?

script.Parent.MouseButton1Click:connect(function(Player)
  print("Button1 Clicked"..Player.Name)
end)

1 answer

MouseButton1Click does not return the player who clicked. You can just use the LocalPlayer if you put the ScreenGui in StarterGui and set its Adornee Property.

######Note: connect is deprecated, use Connect.

local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	print("Button1 Clicked"..Player.Name)
end)

2 comments

0

I tried that and it printed nothing?

0

My bad I hadn't read your question properly. Edited.

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