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

How do I detect parts with tools?

Asked by 10 years ago

I am going to make a dig tool for my game, but I need to know the name of the model I click on? How would I do this, and is there a simple method? Any help would be appreciated.

1 answer

Log in to vote
0
Answered by 10 years ago

Use the mouse.Target method. It gives you the object that the mouse is pointed at.

For example:

local mouse = game.Players.LocalPlayer:GetMouse();
mouse.Button1Down:connect(function()
    print(mouse.Target); --Will print the target that you click on.
end
0
You should mention that this should be in a local script. Aethex 256 — 10y
Ad

Answer this question