|
| 07 May 2014 12:45 PM |
wat if I say; Beast = Math.Random(1, #Player)
would that line actually mean that the Beast is equal to the Player that was picked, so I could then do stuff like BeastSpawn Bricks and stuff? |
|
|
| Report Abuse |
|
|
|
| 07 May 2014 12:51 PM |
Player = game.Players:GetPlayers() Beast = Player[math.random(1,#Player)]
like that,yes |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 07 May 2014 01:24 PM |
math.random(#Player)
is also possible right?
Anyway, STOP COPYING. |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 May 2014 03:52 PM |
| thnx islandmaker, I think I know the other text... also, for me putting a Mesh into the persons Torso, how would I clone() it properly? cos I get so confused with these things sometimes... |
|
|
| Report Abuse |
|
|
|
| 07 May 2014 03:58 PM |
local players = game.Players:GetPlayers() local beast = players[math.random(#players)] |
|
|
| Report Abuse |
|
|
|
| 07 May 2014 05:10 PM |
| thnx guys, also, how would I put him onto a Team? like Bright Red |
|
|
| Report Abuse |
|
|
|
| 07 May 2014 05:16 PM |
Using math.random to pick players are highly unfair. Math random will NOT give you a fair amount of randomness. One player will be Beast 10 times in a row before any other gets a chanse.
For me I choose to go with local players = game.Players:GetPlayers() local v = game.Workspace.DistributedGameTime%#players+1 Beast = players[v]
Works much better in these cases.. |
|
|
| Report Abuse |
|
|
|
| 07 May 2014 05:40 PM |
| lol I was gonna ask about that, but I thought that most people will refuse to help... and btw, I have a leaderstat called RW (Rounds Waited) and I wwould like that to be the chance of the player becoming the beast, and then wen he becomes the beast, his RW is reset inside the system so he doesnt keep becoming the beast over and over, but the visual RW (on the leaderboard) would stay the same for showwing of or maybe to see how much u've played... |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 09 May 2014 06:11 AM |
| Not gonna help u copy games. |
|
|
| Report Abuse |
|
|
|
| 09 May 2014 06:12 AM |
local Players = game.Players:GetPlayers() --Get Players local TopHat = { } --Don't question this magic :3
for _, Player in pairs(Players) do --Repeat through players for i=1, Player.leaderstats.RW.Value do --Repeat steps #of Rounds Waited... TopHat[#TopHat + 1] = Player --Add player to tophat #of rounds waited. end end
local Beast = TopHat[math.random(1, #TopHat)] --Get random player
print(Beast.Name) --Beast will return a player value.
--Remember to set rounds waited back to 1 all the time, otherwise it seems it would be unstable. |
|
|
| Report Abuse |
|
|
|
| 09 May 2014 06:13 AM |
local players = game.Players:GetPlayers() local maxvalue = 0; for i = 1,#players do maxvalue = maxvalue + players[i].RW.Value end
local v = game.Workspace.DistributedGameTime%maxvalue+1 local currentmax = 0; for i = 1,#players do currentmax = currentmax + players[i].RW.Value if (v < currentmax) then Beast = players[i] end end
havnt tested it but i think u get the idea |
|
|
| Report Abuse |
|
|
|
| 09 May 2014 06:19 AM |
to get a random player, whether for beast, choosing a random map, or heck, choosing a random name like Alpha, Delta, Gamma, Kilo, etc., you need to do one of two things.
1) Set up a table.
to set up a table, you can use :GetChildren() if its an object, or, t = {"Alpha","Delta","Gamma","Kilo"} is a name table.
2) choose a random object within that table.
to choose a random object, you use math.random(min,max) before we relate that to tables, you can access things inside of tables with numbers.
a = t[1] -- alpha d = t[2] -- delta g = t[3] -- gamma
and so on. Using that same method, if we want a random thing inside the table, we use math.random(min,#stuff in that table)
t[math.random(1,#t)]
Thus, in conclusion, you can get all the players in a table using :GetChildren(), and then pick a random one like so:
players=game.Players:GetChildren() killer = players[math.random(1,#players)] print(killer.Name.." is the killer!")
|
|
|
| Report Abuse |
|
|
|
| 09 May 2014 08:08 AM |
| thnx all u guys :D and those who say I copy... well I dont! loleris inspired me to do something like his, but different... also, I want a Mesh to be inserted into the Beast, how would I do that? cos am a lil confused with clone() cos sometimes it sAys clone().Parent but if I were to make a new Instance and copy the ID and TextureID then I wouldnt know if my script was right or wrong... and if I wanted to select also, like there's juggernaut, I wanna have Enforcer in my Game... with different Chance Stats though... |
|
|
| Report Abuse |
|
|
|
| 09 May 2014 08:10 AM |
| would I just add another paragraph (but not GetPlayers() again cos it was already done) and just instead of Beast type Enforcer and for chance type other stuff? |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 May 2014 08:38 AM |
| also, how would I take the Title of the Beast and Enforcer after the Round has ended? |
|
|
| Report Abuse |
|
|
|
| 09 May 2014 09:10 AM |
for the Beats Mesh, do I do like local Beast = game.Players.GetBeastFromCharacter? |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 May 2014 12:09 PM |
bad argument #2 to 'random' (interval is empty) thats for the local Beast = TopHat[math.random(1, #TopHat)] cos the thing on top was local TopHat = { } and nothing on top of it cos its not a thing that gets something, it only indicates howw much chance u got... so wat will I do to remove this problem??? |
|
|
| Report Abuse |
|
|
|
| 09 May 2014 12:24 PM |
| plz guys, am so close to finishing the Basic stuff in this Game... only a lil left... |
|
|
| Report Abuse |
|
|