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

How do I make a script detect if I'm clicking a part while holding something in my hand?

Asked by 4 years ago
Edited 4 years ago

Let's say I have a hammer in my hand and I want to use it to open a door by clicking the door while I have the hammer in my hand. How do I do that? Just so it's clear, I'm not asking how I make it so if I touch the door with the hammer, the properties change. All I know is I just insert a ClickDetector and that's it. When you're answering my question, please provide the script and a proper explaination, it can be really long or really short as long as it is easy to understand the script.

1 answer

Log in to vote
0
Answered by
emervise 123
4 years ago
Edited 4 years ago

Try looking into mouse.target and tool.Activaited Example:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse
local tool = plr.Backpack.Tool

tool.Activaited:Connect(function(
    if mouse.target == game.Workspace.part then
        print("we found the part!")
    else
        print("Not the part :(")
    end
end
    )
0
Will error at lines 02, 05 and 06, and please don't give scripts, scripting helpers is not a request website Leamir 3138 — 4y
0
Sorry emervise 123 — 4y
Ad

Answer this question