Hi. I'm still learning LUA.. and i was interested in how would i make a script that would randomly choose a user who is playing to be something? Like the stalker,killer etc.
(Continuation after owen)
And to pick somebody that hasn't already been picked for something, do something similiar to this:
local Plrs = game.Players:GetPlayers() -- Add all players to Plrs table local killer = Plrs[math.random(1,#Players)] -- Get a player, this player is defined under Plr1 local sherif1, sherif2; repeat sherif1, sherif2 = Plrs[math.random(1,#Players)], Plrs[math.random(1,#Players)] until sherif 1 ~= killer and sherif2 ~= killer and sherif1 ~= sherif2
And, yes, you can also use for loops when using a table with multiple already picked people.
This is a very simple question, here is example code:
local Plrs = game.Players:GetPlayers() -- Add all players to Plrs table Plr1 = Plrs[math.random(1,#Players)] -- Get a player, this player is defined under Plr1
Here is the ROBLOX wiki documentation.
Locked by TheMyrco
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?