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

Math.Random Cutsom Value (Not So Random)?

Asked by 6 years ago

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!

0
math.randomseed(123) fanofpixels 718 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

0
smart, I didn't think of doing that, but I feel dumb now lol. FlippinAwesomeCrew 62 — 6y
0
if this helped would you mind accepting the answer? PoePoeCannon 519 — 6y
0
and no problem! PoePoeCannon 519 — 6y
0
yah, and one thing, for math.random is it ok if you do 1,4 or 4? FlippinAwesomeCrew 62 — 6y
View all comments (2 more)
0
yes, it is the same thing. Sorry that's just a habit of mine coming from other languages! PoePoeCannon 519 — 6y
0
great! FlippinAwesomeCrew 62 — 6y
Ad

Answer this question