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

Making something repeat for ever? [UNSOLVED!]

Hi i have a script that removes a few parts and clones a few but after it finishes it doesnt do it again even though i used repeat until and at the until i Nevers value is just a variable that will never change so the script will always repeat.

repeat
wait(20)
game.Workspace.Block.CanCollide = false
wait(77)
game.Workspace.Train:remove()
game.ReplicatedStorage.Train:Clone().Parent = game.Workspace
game.Workspace.Train:MakeJoints()
game.Workspace.Block.CanCollide = true
game.ReplicatedStorage.SpawnAll:Clone().Parent = game.Workspace
wait(4)
game.Workspace.SpawnAll:remove()
game.Workspace.Block.CanCollide = true
until
game.Workspace.Never.Value == 1

Fore some reason the script only does this once and doesnt repeat like it should

2 comments

0

Why is line 14 necessary? If it is an 'IntValue' type instance, and it's Value property is equal to '1', then the loop WILL stop, Also, the 'until' keyword is the code that ENDS the block of code, but also says 'repeat code until condition', meaning it will REPEAT the code inside the loop UNTIL the CONDITION is MET.

0

@SirKitten; We don't have any idea why your code isn't repeating. Even just the way you have it, nothing indicates that the code is broken in any way. Are you getting any errors in the Output? The long waits may be hiding the fact that some part of your code is broken.

3 answers

If you want it to repeat try this... If it works I'll explain why.

Script #1

repeat
wait(20)
game.Workspace.Block.CanCollide = false
wait(77)
game.Workspace.Train:remove()
game.ReplicatedStorage.Train:Clone().Parent = game.Workspace
game.Workspace.Train:MakeJoints()
game.Workspace.Block.CanCollide = true
game.ReplicatedStorage.SpawnAll:Clone().Parent = game.Workspace
wait(4)
game.Workspace.SpawnAll:remove()
game.Workspace.Block.CanCollide = true
until
game.Workspace.Never.Value >= 1

Script #2


while true do
wait(20)
game.Workspace.Block.CanCollide = false
wait(77)
game.Workspace.Train:remove()
game.ReplicatedStorage.Train:Clone().Parent = game.Workspace
game.Workspace.Train:MakeJoints()
game.Workspace.Block.CanCollide = true
game.ReplicatedStorage.SpawnAll:Clone().Parent = game.Workspace
wait(4)
game.Workspace.SpawnAll:remove()
game.Workspace.Block.CanCollide = true


end


Script #3

while wait() do
wait(20)
game.Workspace.Block.CanCollide = false
wait(77)
game.Workspace.Train:remove()
game.ReplicatedStorage.Train:Clone().Parent = game.Workspace
game.Workspace.Train:MakeJoints()
game.Workspace.Block.CanCollide = true
game.ReplicatedStorage.SpawnAll:Clone().Parent = game.Workspace
wait(4)
game.Workspace.SpawnAll:remove()
game.Workspace.Block.CanCollide = true


end

Look for other loops if they don't work. They all do the same thing.

2 comments

0

No im not narbish, it just doesnt repeat, and i did wait, and the wait(whatever) they are there for the timing of my script. Anways thanks everyone for answers

0

Was there anything in the output?

While loops repeat something until the condition between the while and do keywords equals false. If you make the condition something that will never equal false, then it will run forever.

The best way to give it a condition that never equals false is to simply give it the word true. Obviously, true will never equal false, as that would just go completely against all three laws of logic.

while true do
	wait()
	print("Spamming your output...")
end

Remember that eternal loops must have at least a wait(0) inside them somewhere, or else they will crash your game.

This is how you make an eternal loop -- if your script still won't work it's either because it's disabled or there's some other error inside of the loop. Please include all output errors (that have to do with your script) in your post.

this should work~

while true do
wait(20)
game.Workspace.Block.CanCollide = false
wait(77)
game.Workspace.Train:remove()
game.ReplicatedStorage.Train:Clone().Parent = game.Workspace
game.Workspace.Train:MakeJoints()
game.Workspace.Block.CanCollide = true
game.ReplicatedStorage.SpawnAll:Clone().Parent = game.Workspace
wait(4)
game.Workspace.SpawnAll:remove()
game.Workspace.Block.CanCollide = true


end

6 comments

0

no DOESNT WORK!

5

How exactly does it not work? while true do is the more or less 'official' way to write an infinite loop in Lua.

2

I think his logic is wrong somewhere in his script. Not the loop itself.

0

It looks like to me the SirKitten2000 is just going all narbish and using LONG waits() and that can make this script not run for a while then making the owner think its not working. #Narbish

0

It doesnt repeat im not sure how to make it any eaiser to you @adark and @MessorAdmin the Long waits() are needed for the timing of my script.

0

And btw thanks for the stuiped down rank i think im at like -17 now, this site rank idea sucks

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