Game jumps right to the end when it starts up

If you’re so lost on this subject you should probably read the many duplicate threads created about it to get yourself oriented. Among those threads, there’s a few tutorials that are out there. (I found these videos on a thread listed above, and it was marked as a solution.)

2 Likes

Okay, I think I understand what you could do in this situation.

local Active = true
local GameLength = 60
local Label = --insert your label here
local Val = --value here; make sure to set it to 50 by default


while Active == true do
	Val.Value = Val.Value - 1
       Label.Text = (Val.Value)
	--code here
	--when game ends do
	Val.Value = 50
	Active = false
end

Just what you will need to incorporate for this to work out.

Remember to use a IntValue. Place this in a area that will be accessible.

There was nothing wrong with the for loop structure, I don’t see why you can’t use it.

local GameLength = 50

for i=GameLength, 0, -1 do
    -- Checks every second b/c a person might die and such
    wait(1)
end

Just insert the checks every second and you got a working loop.

The issue is with this part, not the for loop itself:

Problem is, the loop will instantly jump to the end. It doesn’t matter if there is any wait in it; the game is only checking for the loop and seeing if it is going to end or not.

I don’t understand what you mean by that being the problem, the loop is what’s causing most of the issue as on the second that the loop is asked to start; it will start going through each one of the numbers with 0 delay.

Not because of the for loop but because of the code inside of it. There is a wait(1) at the bottom.

Loops are asynchronous first off; he was right in his for loop coding. Second off @epicrobloxmaster22 I suggest you comment out checks individually to see which one is the issue if you wish to continue using the code you made.

1 Like

I think It is a Problem With my script So I am going to re read My script to see if I see it

Found My Own Problem I did some Testing and Well its
for i = GameLength,0,-1 do

Yes you do need a second comma there.

Next Time I am not trying loops Im going to stick to my basics

I’m honestly surprised nobody noticed for this long. Kudos for solving your own issue.

2 Likes

You guys are the PROS to Me so When you guys couldn’t find it out and I did I celebrated A little :slight_smile: