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

How to make a door smoothly go up after it is already down?

Asked by 3 years ago

Yooo, so I am making a game where you press a button and a door goes down and when you press it the second time, the door goes up.... but I have no idea how to make it go up after it goes down.

Here is the script to make the door go down

local part = game.Workspace.Door1 local ClickDetector = Instance.new("ClickDetector") local TweenService = game:GetService("TweenService") ClickDetector.Parent = script.Parent ClickDetector.MouseClick:Connect(function()

1local goal = {}
2goal.Position = Vector3.new(part.Position.X, part.Position.Y-10, part.Position.Z)
3 
4local tweenInfo = TweenInfo.new(1)
5 
6local tween = TweenService:Create(part, tweenInfo, goal)
7 
8tween:Play()

end)

0
Idk Why the script appears like 2 parts, the part above the actual script is part of the script as well austenman123 2 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago

You can have a variable that changes when it goes up and then down.

01local Variable == up
02ClickDetector.MouseClick:Connect(function()
03    if Variable == up then
04        Variable = down
05        local goal = {}
06        goal.Position = Vector3.new(part.Position.X, part.Position.Y-10, part.Position.Z)
07 
08        local tweenInfo = TweenInfo.new(1)
09 
10        local tween = TweenService:Create(part, tweenInfo, goal)
11 
12        tween:Play()
13    elseif Variable == down then
14        Variable = up
15        local goal = {}
View all 24 lines...
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
01local Variable == up
02ClickDetector.MouseClick:Connect(function()
03    if Variable == up then
04        Variable = down
05        local goal = {}
06        goal.Position = Vector3.new(part.Position.X, part.Position.Y-10, part.Position.Z)
07 
08        local tweenInfo = TweenInfo.new(1)
09 
10        local tween = TweenService:Create(part, tweenInfo, goal)
11 
12        tween:Play()
13    elseif Variable = down then
14        Variable = up
15        local goal = {}
View all 24 lines...

This is the same as @Justin's exepct Without the two equal Signs

Log in to vote
0
Answered by 3 years ago

I keep getting this error when using your idea @Justin

Workspace.Part.Script:5: Expected identifier when parsing expression, got '=='

0
I didn't mean to put 2 equal signs on the first line. Just remove one of them JustinWe12 723 — 3y

Answer this question