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

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

Asked by
Gigaset39 111
2 years ago
Edited 2 years ago

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

Log in to vote
2
Answered by
SuperPuiu 497 Moderation Voter
2 years ago

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.

0
Mersi SuperPuiu, r?mân dator cu un suc. :D Gigaset39 111 — 2y
0
Cu placere! SuperPuiu 497 — 2y
Ad

Answer this question