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

I want to Randomize this ”levels”, I just Dont know how.some help? :D

Asked by
Gigaset39 111
3 years ago

im doing a Simon Say kind game,but i want to randomize the ”levels”,i have no idea how.

blue = script.Parent.B
yellow = script.Parent.Y
red = script.Parent.R
green = script.Parent.G

  while true do
hint = Instance.new('Hint')
hint.Parent = workspace
hint.Text = 'Get Ready'
wait(4)
hint.Text = 'RED'
wait(6)
blue.Transparency = 1
blue.CanCollide = false

yellow.Transparency = 1
yellow.CanCollide = false

green.Transparency = 1
green.CanCollide = false
wait(10)
blue.Transparency = 0
blue.CanCollide = true

yellow.Transparency = 0
yellow.CanCollide = true

green.Transparency = 0
green.CanCollide = true


hint.Text = 'BLUE'
wait(6)
red.Transparency = 1
red.CanCollide = false

yellow.Transparency = 1
yellow.CanCollide = false

green.Transparency = 1
green.CanCollide = false
wait(10)    
yellow.Transparency = 0
yellow.CanCollide = true

red.Transparency = 0
red.CanCollide = true

green.Transparency = 0
green.CanCollide = true


hint.Text = 'GREEN'
wait(6)

red.Transparency = 1
red.CanCollide = false

blue.Transparency = 1
blue.CanCollide = false

yellow.Transparency = 1
yellow.CanCollide = false

wait(10)
red.Transparency = 0
red.CanCollide = true

blue.Transparency = 0
blue.CanCollide = true

yellow.Transparency = 0
yellow.CanCollide = true


hint.Text = 'YELLOW'
wait(6)

red.Transparency = 1
red.CanCollide = false

blue.Transparency = 1
blue.CanCollide = false

green.Transparency = 1
green.CanCollide = false

wait(10)
red.Transparency = 0
red.CanCollide = true

blue.Transparency = 0
blue.CanCollide = true

green.Transparency = 0
green.CanCollide = true

end

1
Please don't post a question more than once. Furthermore, you are not elaborating enough on your question. 1 line of explanation is not enough for someone to fully understand your code. Provide more detail and please, don't ask a question more than once. Soban06 410 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

You need to loop the script and fire math.random() each time it repeats, then use an if statement to check the number. For Example:

local WaitTime = 5 --Speed of the loop in seconds.

while true do --Loops until script is turned off.
    print("Get Ready")
    wait(3)

    local Roll = math.random(1,4) --Rolls Red, Blue, Green or Yellow,

    if Roll == 1 then --If it rolls red (1)
        print("Red")
    elseif Roll == 2 then --If it rolls blue (2)
        print("Blue")
    elseif Roll == 3 then  --If it rolls green (3)
        print("Green")
    elseif Roll == 4 then --If it rolls yellow (4)
        print("Yellow")
    end

    wait(WaitTime)
end

The "local WaitTime" is how long the script will wait after the loop.

We then make the script repeat until the script is turned off with "while true do" The script prints "Get Ready" in the console and it waits 3 seconds. After the 3 seconds, it'll roll a number from 1 to 4.

The rest explained in the script.

0
Thankyou soo much,You now how to explain things,Thanks again. Gigaset39 111 — 3y
Ad

Answer this question