Elevator Doesn't Go Down Help

Hello, I have a variable and it’s different when I print the same exact thing.

Print: ElavatorScript:25 down -1 1

Script:

local Elavator = workspace.Levels.Elavator
		
if goal_level > current_level then
	goal_level = (goal_level - current_level)
elseif goal_level == current_level then
	return
else
	goal_level = current_level - goal_level*-2
	print("down", current_level - goal_level*2, goal_level) -- Prints "down, -1, 1"
end	
	
current_level = goal_level

	
local goal = Elavator.PrimaryPart.CFrame * CFrame.new(0, goal_level * 16, 0)
	
local distance = (Elavator.PrimaryPart.Position - goal.Position).Magnitude
local elavatorTweenInfo = TweenInfo.new(distance/8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

local tween = TweenService:Create(Elavator.PrimaryPart, elavatorTweenInfo, {CFrame = goal})
tween:Play()
tween.Completed:Wait()

Thank you

The goal_level variable seems to be using a negative 2 while the print function under it uses a positive 2. Also, the goal_level variable would get changed before it hits the print function. So, its printing the current level minus the goal level, then just print goal level

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.