#Why doesn't it work??

38 messages · Page 1 of 1 (latest)

grand fulcrum
#

I dont know???

woven tinsel
#

You have to substitute n with a number or make a another variable with the identifier n outside of the while loop and function

woven tinsel
#

yeah

silent roostBOT
#

studio** You are now Level 1! **studio

woven tinsel
#

should work

grand fulcrum
woven tinsel
#

inside of the while loop

grand fulcrum
#

because it ends when the loop variable value is 5

#

or more

woven tinsel
#

oh wait try instead of Random, math.random()

grand fulcrum
#

am I trying something too difficult?

woven tinsel
#

no no

#

give me a second

#

do you want to keep the transparency when the function is run again?

#

@grand fulcrum

woven tinsel
#
function ColorRandom(n)
    if n == 1 then
        workspace.Part.BrickColor = BrickColor.new(math.random(100))
    else
        workspace.Part.Transparency = 0.75
    end
    wait(4)
end

local loop = 0

while loop < 5 do
    
    local n = math.random(2)
    ColorRandom(n)
    loop += 1
end```
#

that should work

grand fulcrum
woven tinsel
#

is it in a server script? (a normal script)

silent roostBOT
#

studio** You are now Level 2! **studio

grand fulcrum
#

I put it in a local script

woven tinsel
#

local scripts don't work in the workspace

grand fulcrum
#

Oh

#

I didnt know mb

grand fulcrum
#

Maybe it was just a luck thing

woven tinsel
#

yeah because of math.random

#

if you dont want it to be transparent then you can remove the else statement

grand fulcrum
#

It worked!

woven tinsel
#

👍