I am trying to make a door when a tool touches it allows you to walk through and the barricades will fall off.
Door Script:
function ontouch(hit) local Crowbar = hit:findFirstChild("Crowbar") if Crowbar then script.Parent.Transparency = 0.6 script.Parent.CanCollide = false else print("Script Not Working") end end script.Parent.Touched:Connect(ontouch)
Barricade Script:
function ontouch(hit) local Crowbar = hit:findFirstChild("Crowbar") if Crowbar then script.Parent.Anchored = false end end script.Parent.Touched:Connect(ontouch)
If the problem is the crowbar not being detected, then it's probably because of the 'hit' argument returning the handle part of the crowbar already, so no need to search for the crowbar again. Just check if the handle is inside a tool named "Crowbar" or not.
local Tool = hit.Parent if Tool and Tool.Name == "Crowbar" then -- do something end