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

What is wrong with this random player picker?

Asked by 10 years ago
local Players = game.Players:GetPlayers() 
local RandomPlayer = Players[math.random(1,#Players)] 
RandomPlayer.Character:BreakJoint()

I got this in output.

Workspace.Script:2: bad argument #2 to 'random' (interval is empty)

0
Somehow you are managing to have 0 players. If this is running at the start of a game, that's why. It should also be noted that `BreakJoint` is missing an "s" at the end. User#2 0 — 10y

4 answers

Log in to vote
0
Answered by 10 years ago

Error at line 3: You did :BreakJoint(), the script probly took it as a 'nil' value. Try :BreakJoints() instead. :P I hope this helped!

Ad
Log in to vote
0
Answered by
KAAK82 16
10 years ago

hmmm... nearly everything seems correct... but don't do BreakJoints(), dobreakjoints() cos I tried that once, and I got an error so I kno that it should be loercase...

Log in to vote
-1
Answered by 10 years ago

Well, I think it's because it needs to be a in a table.

Log in to vote
-1
Answered by 10 years ago
game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())] breakjoints

Probably something like that.

Answer this question