player = game.Players.LocalPlayer tool = script.Parent handle = tool.Handle function onClicked() handle.BrickColor = BrickColor.new("Bright red") end tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(onClicked) end)
I have this so when I played clicks it changes the color of the handle, but how can I make it check what the player has clicked, like if onClicked.Name == "Dirt" then print("You clicked on dirt")
Try putting a ClickDetector in anything that can be clicked, and include a script in it. Make the script have the following:
script.Parent.ClickDetector.MouseClick:connect(function() print("You clicked on " .. script.Parent.Name.. "!") end)