Howdy howdy, my door script has recently started to malfunction. Every now and then when opening the door, it has a spasm for no reason. This has nothing to do with collisions, as I have tried turning them off. Here is a video of it.
Here’s my script.
for _,unlocked in pairs(game.Workspace.Doors.Unlocked:GetChildren()) do
local Can = true
local prompt = unlocked.Prompt.ProximityPrompt
local prompt2 = unlocked.Prompt2.ProximityPrompt
local hinge = unlocked.Hinge
Open = false
prompt.Enabled = true
prompt2.Enabled = true
prompt.Triggered:Connect(function(player)
if prompt.ActionText == "Open Door" and prompt2.ActionText == "Open Door" then
Open = true
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Close Door"
prompt2.ActionText = "Close Door"
hinge.Opening:Play()
local finish1 = unlocked.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = unlocked.PrimaryPart.CFrame:lerp(finish1,i)
unlocked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
wait(5)
if prompt.ActionText == "Close Door" and prompt2.ActionText == "Close Door" then
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Open Door"
prompt2.ActionText = "Open Door"
hinge.Closing:Play()
local finish2 = unlocked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = unlocked.PrimaryPart.CFrame:lerp(finish2,i)
unlocked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
elseif prompt.ActionText == "Close Door" and prompt2.ActionText == "Close Door" then
Open = false
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Open Door"
prompt2.ActionText = "Open Door"
hinge.Closing:Play()
local finish = unlocked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = unlocked.PrimaryPart.CFrame:lerp(finish,i)
unlocked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
end)
prompt2.Triggered:Connect(function(player)
if prompt2.ActionText == "Open Door" and prompt.ActionText == "Open Door" then
Open = true
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Close Door"
prompt.ActionText = "Close Door"
hinge.Opening:Play()
local finish1 = unlocked.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = unlocked.PrimaryPart.CFrame:lerp(finish1,i)
unlocked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt2.Enabled = true
prompt.Enabled = true
wait(5)
if prompt2.ActionText == "Close Door" and prompt.ActionText == "Close Door" then
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Open Door"
prompt.ActionText = "Open Door"
hinge.Closing:Play()
local finish2 = unlocked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = unlocked.PrimaryPart.CFrame:lerp(finish2,i)
unlocked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
elseif prompt2.ActionText == "Close Door" and prompt.ActionText == "Close Door" then
Open = false
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Open Door"
prompt.ActionText = "Open Door"
hinge.Closing:Play()
local finish = unlocked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = unlocked.PrimaryPart.CFrame:lerp(finish,i)
unlocked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt2.Enabled = true
prompt.Enabled = true
end
end)
end
--locked
for _,locked in pairs(game.Workspace.Doors.Locked:GetChildren()) do
local Can = true
local prompt = locked.Prompt.ProximityPrompt
local prompt2 = locked.Prompt2.ProximityPrompt
local hinge = locked.Hinge
Open = false
prompt.Enabled = true
local group = locked.Value.Value
prompt.Triggered:Connect(function(player)
if prompt.ActionText == "Open Door" and prompt2.ActionText == "Open Door" and player:IsInGroup(group) then
Open = true
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Close Door"
prompt2.ActionText = "Close Door"
hinge.Opening:Play()
local finish1 = locked.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
for i = 0,7,.1 do
local cfm = locked.PrimaryPart.CFrame:lerp(finish1,i)
locked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
wait(5)
if prompt.ActionText == "Close Door" and prompt2.ActionText == "Close Door" then
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Open Door"
prompt2.ActionText = "Open Door"
hinge.Closing:Play()
local finish2 = locked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = locked.PrimaryPart.CFrame:lerp(finish2,i)
locked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
elseif prompt.ActionText == "Close Door" and prompt2.ActionText == "Close Door" and player:IsInGroup(group) then
Open = false
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Open Door"
prompt2.ActionText = "Open Door"
hinge.Closing:Play()
local finish = locked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = locked.PrimaryPart.CFrame:lerp(finish,i)
locked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
end)
prompt2.Triggered:Connect(function(player)
if prompt2.ActionText == "Open Door" and prompt.ActionText == "Open Door" and player:IsInGroup(group) then
Open = true
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Close Door"
prompt.ActionText = "Close Door"
hinge.Opening:Play()
local finish1 = locked.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = locked.PrimaryPart.CFrame:lerp(finish1,i)
locked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt2.Enabled = true
prompt.Enabled = true
wait(5)
if prompt2.ActionText == "Close Door" and prompt.ActionText == "Close Door" then
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Open Door"
prompt.ActionText = "Open Door"
hinge.Closing:Play()
local finish2 = locked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = locked.PrimaryPart.CFrame:lerp(finish2,i)
locked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
elseif prompt2.ActionText == "Close Door" and prompt.ActionText == "Close Door" and player:IsInGroup(group) then
Open = false
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Open Door"
prompt.ActionText = "Open Door"
hinge.Closing:Play()
local finish = locked.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,0.7,.1 do
local cfm = locked.PrimaryPart.CFrame:lerp(finish,i)
locked:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt2.Enabled = true
prompt.Enabled = true
end
end)
end
--garage
for _,garage in pairs(game.Workspace.Doors.Garage:GetChildren()) do
local Can = true
local prompt = garage.Prompt.ProximityPrompt
local prompt2 = garage.Prompt2.ProximityPrompt
local hinge = garage.Hinge
Open = false
prompt.Enabled = true
local group = garage.Value.Value
prompt.Triggered:Connect(function(player)
if prompt.ActionText == "Open Door" and prompt2.ActionText == "Open Door" and player:IsInGroup(group) then
Open = true
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Close Door"
prompt2.ActionText = "Close Door"
hinge.Opening:Play()
local finish1 = garage.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(85),0)
for i = 0,0.7,.005 do
local cfm = garage.PrimaryPart.CFrame:lerp(finish1,i)
garage:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
wait(10)
if prompt.ActionText == "Close Door" and prompt2.ActionText == "Close Door" then
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Open Door"
prompt2.ActionText = "Open Door"
hinge.Closing:Play()
local finish2 = garage.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(85),0)
for i = 0,0.7,.005 do
local cfm = garage.PrimaryPart.CFrame:lerp(finish2,i)
garage:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
elseif prompt.ActionText == "Close Door" and prompt2.ActionText == "Close Door" and player:IsInGroup(group) then
Open = false
prompt.Enabled = false
prompt2.Enabled = false
prompt.ActionText = "Open Door"
prompt2.ActionText = "Open Door"
hinge.Closing:Play()
local finish = garage.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(85),0)
for i = 0,0.7,.005 do
local cfm = garage.PrimaryPart.CFrame:lerp(finish,i)
garage:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
end)
prompt2.Triggered:Connect(function(player)
if prompt2.ActionText == "Open Door" and prompt.ActionText == "Open Door" and player:IsInGroup(group) then
Open = true
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Close Door"
prompt.ActionText = "Close Door"
hinge.Opening:Play()
local finish1 = garage.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(85),0)
for i = 0,0.7,.005 do
local cfm = garage.PrimaryPart.CFrame:lerp(finish1,i)
garage:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt2.Enabled = true
prompt.Enabled = true
wait(10)
if prompt2.ActionText == "Close Door" and prompt.ActionText == "Close Door" then
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Open Door"
prompt.ActionText = "Open Door"
hinge.Closing:Play()
local finish2 = garage.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(85),0)
for i = 0,0.7,.005 do
local cfm = garage.PrimaryPart.CFrame:lerp(finish2,i)
garage:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt.Enabled = true
prompt2.Enabled = true
end
elseif prompt2.ActionText == "Close Door" and prompt.ActionText == "Close Door" and player:IsInGroup(group) then
Open = false
prompt2.Enabled = false
prompt.Enabled = false
prompt2.ActionText = "Open Door"
prompt.ActionText = "Open Door"
hinge.Closing:Play()
local finish = garage.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(85),0)
for i = 0,0.7,.005 do
local cfm = garage.PrimaryPart.CFrame:lerp(finish,i)
garage:SetPrimaryPartCFrame(cfm)
wait()
end
wait(0.4)
prompt2.Enabled = true
prompt.Enabled = true
end
end)
end