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

How to check what a tool has clicked?

Asked by 9 years ago
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")

1 answer

Log in to vote
0
Answered by
bloxxyz 274 Moderation Voter
9 years ago

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)
0
That would not work because clicking ClickDetectors with a tool selected does not work. SlickPwner 534 — 9y
0
^ yeah and it must be with a tool, cause im making a game kinda like minecraft, but you need a tool to mine the block NinjoOnline 1146 — 9y
Ad

Answer this question