I'm trying to make a door that opens when you click a button. Then I want it to close after you click the same button. It opens but does not close. The print message "closing" that I have printed so it's a problem with the tween2 I believe. Any ideas?
local TweenService = game:GetService("TweenService")
local button = game.Workspace.Button.ClickDetector
local door = script.Parent
local tweenInfo = TweenInfo.new(3,Enum.EasingStyle.Cubic,Enum.EasingDirection.InOut,0,false)
local opened = {}
opened.Position = Vector3.new(-36.9, 2.9, -19.675)
local yolk = {}
door.Position = Vector3.new(-31.75, 2.9, -19.675)
local tween1 = TweenService:Create(door,tweenInfo,opened)
local tween2 = TweenService:Create(door,tweenInfo,yolk)
local function yeetSwag()
if door.Position == Vector3.new(-36.9, 2.9, -19.675) then
print("closing")
tween2:Play()
else
print("opening...")
tween1:Play()
end
end
button.MouseClick:Connect(yeetSwag)

2 comments
The yolk was just a variable for the door's closed position.
The yolk actually worked. I forgot I was supposed to basically define yolk's properties.