Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-7

Making something repeat for ever? [UNSOLVED!] [closed]

Asked by 10 years ago

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

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. TheeDeathCaster 2368 — 10y
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. adark 5487 — 10y

Locked by TheeDeathCaster and M39a9am3R

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

3 answers

Log in to vote
2
Answered by 10 years ago

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.

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 SirKitten2000 0 — 10y
0
Was there anything in the output? EzraNehemiah_TF2 3552 — 10y
Ad
Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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.

Log in to vote
-1
Answered by 10 years ago

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
0
no DOESNT WORK! SirKitten2000 0 — 10y
5
How exactly does it not work? `while true do` is the more or less 'official' way to write an infinite loop in Lua. adark 5487 — 10y
2
I think his logic is wrong somewhere in his script. Not the loop itself. Necrorave 560 — 10y
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 MessorAdmin 598 — 10y
View all comments (2 more)
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. SirKitten2000 0 — 10y
0
And btw thanks for the stuiped down rank i think im at like -17 now, this site rank idea sucks SirKitten2000 0 — 10y