Hello. i want to make doors that when you touch them they move up. The problem is that once i touch them, they won't stop moving. I can't seem to figure out what is the problem. Here is the script i have
Active = false function OnHit(Touch) if Active == true then return end Active = true for i=1,79 do for _,v in pairs(script.Parent.Parent.Parts:GetChildren()) do v.CFrame = v.CFrame * CFrame.new(0,0.1,0) wait(.01) end wait(3) for i=1,79 do for _,v in pairs(script.Parent.Parent.Parts:GetChildren()) do v.CFrame = v.CFrame * CFrame.new(0,-0.1,0) wait(.01) end Active = false end end end script.Parent.Touched:connect(OnHit)
Can someone help me please?
debounce = false script.Parent.Touched:connect(function(hit) if debounce == true then return end debounce = true if hit.Parent:findFirstChild("Humanoid") then for i = 1,20 do script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0,0,0.5) wait() end wait(1) for i = 1,20 do script.Parent.CFrame = script.Parent.CFrame + Vector3.new(-0,0,-0.5) wait() end end debounce = false end)