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

why isnt math.random random ?

Asked by
Pelard 0
6 years ago
Edited 6 years ago

Alright so this code assigns random images to imagelabels and it works but however when you rejoin the game you can see that it is the same images in the same order.

math.randomseed(tick())

for spin=1,100 do
    wait()
    y = Instance.new("ImageLabel")
u = (math.random(1,100)*100/100)
if u < 33 then
    y.Image = 'http://www.roblox.com/asset/?id=851659838'
else
    if 33 < u and u < 66 then
        y.Image = 'http://www.roblox.com/asset/?id=171155237'
        else
    if 66 < u and u <= 100 then
        y.Image = 'http://www.roblox.com/asset/?id=102106311'
    end
    end
end
0
probably not the cause but you don't need that *100/100 because 100/100 is 1 and that doesn't effect U DanzLua 2879 — 6y

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Try using elseif once in a while

math.randomseed(tick())

for spin=1,100 do
    wait()
    y = Instance.new("ImageLabel")
    u = math.random(1,100)
    if u<33 then
        y.Image = 'http://www.roblox.com/asset/?id=851659838'
    elseif u>=33 and u<66 then
        y.Image = 'http://www.roblox.com/asset/?id=171155237'
    elseif u>=66 then
        y.Image = 'http://www.roblox.com/asset/?id=102106311'
    end
end

Your script was messy and that could cause an unnoticed problem because you cant really see what direction its taking

0
i have updated it now , no errors but still same results whenever you join the game Pelard 0 — 6y
0
Try added print() after almost every line, so you can see if the error was there or not. For example, after line 6, add print(u). thesit123 509 — 6y
0
^ yea it'd be good what 'u' is DanzLua 2879 — 6y
0
@Pelard DanzLua 2879 — 6y
Ad

Answer this question