function onTouched(hit)
script.Parent.Door.Transparency = 0.6
wait(0.1)
script.Parent.Door.CanCollide = false
wait(2)
script.Parent.Door.Transparency = 0
wait(0.1)
script.Parent.Door.CanCollide = true
end
script.Parent.Touched:connect(onTouched)
✓ ANSWER ACCEPTED
Door script not working?
1 answer
✓ Accepted answer
Here is what was wrong with your script
1. You didn't what would hit the door (Which would be the humanoid)
function onTouched(hit)
local h = hit.Parent:findFirstChild("Humanoid")
if h~=nil then
script.Parent.Door.Transparency = 0.6
wait(0.1)
script.Parent.Door.CanCollide = false
wait(2)
script.Parent.Door.Transparency = 0
wait(0.1)
script.Parent.Door.CanCollide = true
end
end
script.Parent.Door.Touched:connect(onTouched)
You can change the last line to however you set it as, I just added door, for it to work for me since, I don't know what the model is set up for the door.
This discussion is preserved as it was. New answers, comments, and votes are closed.
