So I want it so when a player clicks a button it changes the color of a tool in his inventory. I can do that but how do I find the player who clicked? (clickdetector)
A quick check of the wiki turned up this. Basically, the MouseClick
event knows the player that clicked it and we can use that.
--Script is assumed to be placed inside the Part the ClickDetector resides in. function onClicked(player) print("Button clicked by " .. player.Name); --Insert code to adjust the player's tool --Edit: A demonstration of how to do stuff with the player's character, as shown by the example of adding Sparkles to the character's torso. local torso = player.Character:findFirstChild("Torso") if torso == nil then return end local spark = Instance.new("Sparkles") spark.SparkleColor = Color3.new(1, 0, 0) spark.Parent = torso wait(2) spark:Destroy() end script.Parent.ClickDetector.MouseClick:connect(onClicked)