I’m trying to make an automatic sliding door, but the touched and untouched events keep acting up weirdly and I’m not sure why. I tried searching for similar issues but couldn’t find any.
Here is the code;
local open = false
local left = script.Parent.Parent.LeftDoor
local right = script.Parent.Parent.RightDoor
local leftfake = script.Parent.Parent.LeftFake
local rightfake = script.Parent.Parent.RightFake
local leftorigin = script.Parent.Parent.LeftOriginal
local rightorigin = script.Parent.Parent.RightOriginal
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if open == false then
local tween = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, false, 0)
local leftt = tween:Create(left, info, {Position = leftfake.Position})
local rightt = tween:Create(right, info, {Position = rightfake.Position})
leftt:Play()
rightt:Play()
leftt.Completed:Wait()
wait(.1)
open = true
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if open == true then
local tween = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, false, 0)
local leftt = tween:Create(left, info, {Position = leftorigin.Position})
local rightt = tween:Create(right, info, {Position = rightorigin.Position})
leftt:Play()
rightt:Play()
leftt.Completed:Wait()
wait(.1)
open = false
end
end
end)
And here is what happens when I play;