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

How can i tell to a script to run a script 6 times in a row?

how i can tell to a script to run 6 times in a row? like:

       local Dice = math.random(1,3) 
	hint.Value = '3'
	wait(0.9)
	hint.Value = '2'
	wait(0.9)
	hint.Value = '1'
	wait(0.9)
	
	if Dice == 1 then
            P.CanCollide = false
            end

           if Dice == 2 then
            P.CanCollide = false
            end

             if Dice == 3 then
            P.CanCollide = false
            end

            until 6x  --- :D :D :D

You got what i mean? i could copy & paste that, but i don't want to do that, cause it has 12 if Dice ==, so is gona be hard . :D :D

1 answer

✓ Accepted answer

Hello!

I didn't understood much, but from what I think you want the code to repeat 6 times right? Well, there are multiple ways to do that. First: for loop:

for i = 1, 6 then

local Dice = math.random(1,3) 
hint.Value = '3'
task.wait(0.9) -- use task.wait instead of wait
hint.Value = '2'
task.wait(0.9)
hint.Value = '1'
task.wait(0.9)

if Dice == 1 then
        P.CanCollide = false
        end

       if Dice == 2 then
        P.CanCollide = false
        end

         if Dice == 3 then
        P.CanCollide = false
        end

end

Or a repeat loop:

-- Only an example
local numberOfRuns = 0

repeat task.wait()

-- Do something here

numberOfRuns += 1
until numberOfRuns >= 5

Anyways, this is based on what I understood.

2 comments

0

Mersi SuperPuiu, r?mân dator cu un suc. :D

0

Cu placere!

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