So I created this script to open a door when collided with a player, I previously have setup tests, it gets through the whole code but the doors don't open.
local folder = script.Parent
local Door1 = folder.Door1
local Door2 = folder.Door2
local Collision = folder.DoorCollision
local debounce = false
Collision.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
if debounce == true then return end
debounce = true
local finish1 = Door1.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
local finish2 = Door2.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i,v in pairs(Door1:GetChildren()) do
v.CanCollide = false
end
for i,v in pairs(Door2:GetChildren()) do
v.CanCollide = false
end
for i = 0,1,.1 do
local cfm1 = Door1.PrimaryPart.CFrame:lerp(finish1,i)
local cfm2 = Door2.PrimaryPart.CFrame:lerp(finish2,i)
wait()
end
wait(3)
for i = 0,1,.1 do
local cfm1 = Door1.PrimaryPart.CFrame:lerp(finish2,i)
local cfm2 = Door2.PrimaryPart.CFrame:lerp(finish1,i)
wait()
end
for i,v in pairs(Door1:GetChildren()) do
v.CanCollide = true
end
for i,v in pairs(Door2:GetChildren()) do
v.CanCollide = true
end
debounce = false
end)
