|
| 25 Jul 2016 03:37 PM |
So i using a code which will assign teams but i want it to be random? Any help?
local Blue = Instance.new("Team") Blue.TeamColor = BrickColor.new("Bright blue") Blue.Parent = game:GetService('Teams') Blue.Name = "Blue" local Red = Instance.new("Team") Red.TeamColor = BrickColor.new("Bright Red") Red.Parent = game:GetService("Teams") Red.Name = "Red"
-- Assign Randomly T = {"Blue","Red"} plr.Team = (table[math.random(1, #T)]) |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2016 03:38 PM |
| Use math.random and a random seed |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2016 03:43 PM |
| Can you clarify Random, seed? no documentation on it |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2016 03:45 PM |
| Random doesn't exist as far as your computer is concerned. It uses a mathematical process which is known as pseudo-random number generation. To do this, it requires a seed to produce results that appear random. Common practice is to set the seed to tick()%1e6, to do this you'd use the line math.randomseed(tick()%1e6). I'm pretty sure tick() returns the seconds since the start of UNIX time (or something along those lines); as a result it will always be a different number and your pseudo-random outcomes should always be different |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2016 03:48 PM |
| Thanks but how would i go about using it if it was a variable, im guessing the variable would be a specific number? as it is a string |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Jul 2016 03:53 PM |
randomseed is not the random variable - it sets the random generator up to produce random results. You need to change the line:
plr.Team = (table[math.random(1, #T)])
to
plr.Team = T[math.random(1,#T)] |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2016 03:57 PM |
Thank you very much :) You are the only one that has explained the meaning of a function which is really helpful thank you. |
|
|
| Report Abuse |
|
|