Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is wrong with this random player picker?

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)

1 comment

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.

4 answers

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

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...

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

game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())] breakjoints

Probably something like that.

This discussion is preserved as it was. New answers, comments, and votes are closed.