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

Math.Random Cutsom Value (Not So Random)?

So basically I want to make a game where each round a player is reassigned his team, but I want there to be 3x as many players on one team (They have the disadvantage). So I'm using math.random, but how would I make it so that It's still random, just the odds are in one teams favor? Here is the script:

while true do
	wait(5)
	teamchange = math.random(2)
	if teamchange == 2 then
		game.Players.LocalPlayer.TeamColor = BrickColor.new("Really red")
	end
	if teamchange == 1 then
		game.Players.LocalPlayer.TeamColor = BrickColor.new("Dark stone grey")
	end
end

Hope You Can Help, Thanks!

2 comments

0

math.randomseed(123)

1 answer

✓ Accepted answer

what you can do is

while wait(5) do
	teamchange = math.random(1,4)
	if teamchange == 1 then
		game.Players.LocalPlayer.TeamColor = BrickColor.new("Really red")
	else
		game.Players.LocalPlayer.TeamColor = BrickColor.new("Dark stone grey")
	end
end

this way, it has 1 chance out of 4 to be red team, and 3 out of 4 chance to be grey team.

6 comments

0

smart, I didn't think of doing that, but I feel dumb now lol.

0

if this helped would you mind accepting the answer?

0

and no problem!

0

yah, and one thing, for math.random is it ok if you do 1,4 or 4?

0

yes, it is the same thing. Sorry that's just a habit of mine coming from other languages!

0

great!

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