Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sliding door keeps sliding?

Asked by 3 years ago

Hello, I just created a sliding door.

I'm having one issue which is the sliding door keeps sliding more if you keep hitting the zone, which then means it doesn't slide back into position properly.

Code is shown below:

script.Parent.Zone.Touched:Connect(function()
    if not debounce then
        debounce = true
        for i,v in pairs(door1:GetChildren()) do
            tweenServ:Create(door1[v.Name],tweenInfo,{CFrame = CFrame.new(door1[v.Name].Position - Vector3.new(3.6,0,0))}):Play()
        end
        wait(2)
        for i,v in pairs(door1:GetChildren()) do
            tweenServ:Create(door1[v.Name],tweenInfo,{CFrame = CFrame.new(door1[v.Name].Position + Vector3.new(3.6,0,0))}):Play()
        end
        debounce = false
    end
end)

Any suggestions would be appreciated.

0
What is the scope of debounce? centraltrains 60 — 3y
0
what's a scope? Sorry, extreme beginner here ryanaskew 50 — 3y
0
Did you set your debounce to false before the .Touched event? AntiWorldliness 868 — 3y
0
yes, it is set to false before ryanaskew 50 — 3y
View all comments (2 more)
0
is all you parts/Models Spelled right? JordanTheDev_Team 33 — 3y
0
all spelt right, no errors and door works fine apart from the fact it just keeps sliding if I go in and out the zone repeatedly ryanaskew 50 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Stupid mistake on my end, fixed it myself.

Me being an absolute idiot forgot that a :Play() essentially runs it in the background, therefore the script thinks its complete when really the door never finished closing.

All I had to do was add a wait([time for door to close]) at the end so that it could successfully close.

Thanks to everyone who tried to help!

Ad

Answer this question