A block movin' up and down. How long does it take for it to do so?

I was makin’ that elevator the other day, I was able to make it work and stuff, I just have a hard time figurin’ out how long does the ride take in the followin’ script:

local Elevator = script.Parent

while true do
wait(15)
for i = 1,100 do
Elevator:TranslateBy(Vector3.new(0,-1,0))
wait()
end
wait(2)
for i = 1,100 do
Elevator:TranslateBy(Vector3.new(0,1,0))
wait()
end
end

The idea is that by the begginin’ of the game, the elevator waits 15 seconds before goin’ down, and by the end of the ride down it waits 2 seconds, to come back again. The question is HOW LONG does the ride take?

You could use tick()…

local initial = tick()
local Elevator = script.Parent

while true do
wait(15)
for i = 1,100 do
Elevator:TranslateBy(Vector3.new(0,-1,0))
wait()
end
wait(2)
for i = 1,100 do
Elevator:TranslateBy(Vector3.new(0,1,0))
wait()
end
end

print(tick()-initial) -- Prints out the total time it took since initial was declared

…or a stopwatch :smiley:

1 Like

Thank you! I really appreciate it!
And I’m kinda mad at myself I didn’t think’o that! I actually tried usin’ a stopwatch, so please, don’t laugh!

1 Like

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