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

Finding You in ClickDetector?

I have created a button that when is clicked it opens your shop GUI. It works!; except the fact that every time the button is clicked (doesn't matter who) you're shop opens up. Is there a way to make it so that you're shop opens up only if the person that clicked the button is you?

3 answers

✓ Accepted answer

When using a click detector the MouseClick event returns the player who click so:

Workspace.Part.ClickDetector.MouseClick:connect(function(playerWhoClicked)
  print("Part was clicked by: " .. playerWhoClicked.Name)
end)

Basically when doing this the playerWhoClicked you can get the player in game.Players or however you're opening to only open for the player that clicked. For more info on the click detector check out the wiki: Click Detector

1 comment

0

thx for you're help!:D

The MouseClick event returns the player who clicked the ClickDetector. Script:

function onClick(player)
	player.Character.PlayerGui.ShopGui.Enabled = true
end

script.Parent.ClickDetector.MouseClick:connect(onClick(player))

1 comment

0

thank you very much!:D

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