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

Why wont my sliding door that has two buttons work?

I'm trying to make a door that has two buttons but only one button works.

local tweenService = game:GetService("TweenService")


local clickDetector = workspace:WaitForChild("Lever").ClickDetector


local seconds = 11.9


clickDetector.MouseClick:Connect(function()
	wait(2.7)
script.Parent.Rumb:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(-232.523, 75.247, -242.881)}):Play()
wait(30)
script.Parent.Rumb:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(-232.523, 75.247, -182.133)}):Play()
end)

Thanks if you can help!

4 comments

0

So you have two buttons, but one click detector?

0

There are two, one in each button

0

id rather use a for i loop im not a fan of working with tween services

0

By the way I suggest not using explicit cframes but instead using rightVector and multiplying an offset so you don't have to re-edit the script when you want to move the doors.

2 answers

✓ Accepted answer

Not sure if this will work but rename one of the Levers Lever2.

local tweenService = game:GetService("TweenService")


local clickDetector = workspace:WaitForChild("Lever").ClickDetector
local clickDetector2 = workspace:WaitForChild("Lever2").ClickDetector



local seconds = 11.9


clickDetector.MouseClick:Connect(function()
    wait(2.7)
script.Parent.Rumb:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(-232.523, 75.247, -242.881)}):Play()
wait(30)
script.Parent.Rumb:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(-232.523, 75.247, -182.133)}):Play()
end)

clickDetector2.MouseClick:Connect(function()
    wait(2.7)
script.Parent.Rumb:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(-232.523, 75.247, -242.881)}):Play()
wait(30)
script.Parent.Rumb:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(-232.523, 75.247, -182.133)}):Play()
end)

1 comment

0

Thanks

Likely since you named it "Lever" if they have the same name only one of the children will work. Rename the second one "Lever2" and change the WaitForChild() to Lever2 and that should fix it I think.

Edit: For future reference use script.Parent....

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