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

My sliding door with detectors doesn't work, why?

It works but it flies away at incredible speeds. The script uses tweenservice but I really f*ed something up and it does it wrong.

local TweenService = game:GetService("TweenService")
local door1 = script.Parent:WaitForChild("Door1")
local door2 = script.Parent:WaitForChild("Door2")
local tweeningInformation = TweenInfo.new(
    0.5,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local door1Open = {CFrame = CFrame.new(19.75, 3.75, 83.25)}
local door2Open = {CFrame = CFrame.new(2.75, 3.75, 83.25)}
local door1Close = {CFrame = CFrame.new(14.25, 3.75, 83.25)}
local door2Close = {CFrame = CFrame.new(8.25, 3.75, 83.25)}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
local tween2open = TweenService:Create(door1,tweeningInformation,door2Open)
local tween2close = TweenService:Create(door1,tweeningInformation,door2Close)

script.Parent.Detector1.Touched:Connect(function(hit)
    tween1open:Play()
    tween2open:Play()
    wait(5)
    tween1close:Play()
    tween2close:Play()
end)
script.Parent.Detector2.Touched:Connect(function(hit)
    tween1open:Play()
    tween2open:Play()
    wait(5)
    tween1close:Play()
    tween2close:Play()
end)

Note: No errors, just works in a worng way.

https://streamable.com/70sd4

2 comments

0

just so you know the link you put is blocked

0

I mean, you could just copy and paste it.

2 answers

✓ Accepted answer

They are kind of always active, that's why. You need to add a debounce boolvalue, or name it however you want.

Basically, You can make a boolvalue into the door, or make it into the script local debounce = false Then, at the beginning of both functions, if debounce == false then and debounce = true At the end of both debounce = false

I didn't explain it all to you in purpose, try to figure out how to exactly do it yourself.

1 comment

0

It may take me a while to understand what you sadi since I am a bit tired. But thanks a lot man.

It could be that your door1's position and door2's position are wrong, copy their position ID at their original state (for door1Close and door2Close) and their position ID at their new state! (for door1Open and door2Open) Hopefully this helps.

1 comment

0

That's not the problem here. But thanks anyways.

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