Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Sliding door keeps sliding?

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.

6 comments

0

What is the scope of debounce?

0

what's a scope? Sorry, extreme beginner here

0

Did you set your debounce to false before the .Touched event?

0

yes, it is set to false before

0

is all you parts/Models Spelled right?

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

1 answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.