I need to know how to do this because in my new game project math.random only selects 1 player to be the criminal.
here is an example of what I have to make it select 1 person.
criminals = people[math.random(1, #people)]
I need to know how to do this because in my new game project math.random only selects 1 player to be the criminal.
here is an example of what I have to make it select 1 person.
criminals = people[math.random(1, #people)]
The reason is for that theres only 1 player selected is because your using
math.random(1, #people)
The '1' makes it only select one player.
I suggest using a table.
Much easyer to use. Example code :
criminals = {}
for i = 1, math.random(1, 5), 1 do
while wait() do
local NC = people[math.random(1, #people)]
for _,plr in next,criminals do
if plr ~= NC then
table.insert(criminals, NC)
break -- Stop the while loop
end
end
end
end
So now what you can do is much MUCH more simple,
Example
for _,plr in next,criminals do
local Character = workspace:WaitForChild(plr.Name)
local Human = Character:WaitForChild("Humanoid")
Humanoid.Died:connect(function()
print(Character.Name..", died")
end)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment