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

why isnt math.random random ?

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

1 comment

0

probably not the cause but you don't need that *100/100 because 100/100 is 1 and that doesn't effect U

1 answer

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

4 comments

0

i have updated it now , no errors but still same results whenever you join the game

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).

0

^ yea it'd be good what 'u' is

0

@Pelard

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