How would I make it so when you click on a certain object, it activates a script, but only if the player is holding a specific tool? (Example: You need a key to open a door).
The only answers iv'e been able to find all made it so you had to touch the part with the tool, but how would I make it work with clicking instead?
A simple way of doing this is by checking if the player that clicked has that tool in their player model. When a tool is equipped, it will move from their backpack to said model. If you have a click detector in the door and a script in that click detector, you can go about that like so:
script.Parent.MouseClick:Connect(function(plr)) if workspace[plr.Name].Humanoid.Health > 0 then -- make sure they're alive if workspace[plr.Name]:FindFirstChild("--[[Name of your tool]]" then --[[variable for your door]].CanCollide = false --[[variable for your door]].Transparency = 1 end end end)
If this doesn't end up working then feel free to comment. I hope I helped!