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

How do I make my rising platform stop instead of loop?

Hello! So I have this script which works perfect, except I only want it to stop at its very peak, I do not want it to move back down. Here is what I mean:

--this script would be inside the part
local brick=script.Parent --creating a new variable named brick, referencing our part. "script" is a built-in object that references the actual script.
while wait(1) do --wait a second before running the code again
for I=1,10 do --begin a "for" loop, we are going to move the part up very little by little to make it seem like it is sliding.
brick.Position=brick.Position+Vector3.new(0,0.1,0) --add 0.1 on the Y scale (Vertical) to increase the brick's position
wait() --wait a fraction of a millisecond, or else it doesn't appear as a sliding brick.
end --end the "for" loop
wait(1) --pause a second
for I=1,10 do --This section is pretty much just a repeat.
brick.Position=brick.Position+Vector3.new(0,-0.1,0) --subtract 0.1 on the Y scale (Vertical) to decrease the brick's position
wait()
end
end --end the loop

1 comment

0

A good practice is to keep the indentation, it will just cause you more problems in the future if you don't.

1 answer

local brick=script.Parent
while wait(1) do
    for i=.1,1 do --this is an easier way to handle the height
	brick.Position=brick.Position+Vector3.new(0,i,0)
	wait()
    end--all you needed to do was remove the second for loop
end

Since you seem to not understand the basics of scripting, I recommend you look at this video series: https://developer.roblox.com/videos/Intro-to-Scripting-First-Script

5 comments

0

When using for loops, there is always another number in for i=1,10 that you don't see which is after the 2nd number, which tells you how much you go up in. By default, it is set to 1. So that script would not work unless you do for i=.1,1,.1

0

You also linked him to a video of how to print a string, which isn't very helpful.

0

RBLX, it's always bad practice to jump into a completely new subject to a random point that requires previous knowledge of which you do not know completely. It is always best to start from the beginning. And also seeing as how you didn't bother to look at it, I did mention how it was a video series. Series means one video after the other in a specified order.

0

As for your first comment, you didn't need to write a paragraph, I haven't dealt with lua in about 3 months, so am a bit rusty.

0

You say that, but you write a paragraph on how I missed the fact that you said series and that it's bad practice to jump into lua without knowing what you're doing (which I agree with) but it seems he knows what he's doing unless he got it from a youtube video or another source.

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