Hello! I'm making a game where a random player is chosen as a human, and the others are chosen as plushies. I get the error (stated in the title). Could I get some help with this?
Code:
wait(11)
while true do
h = Instance.new ("Message")
p = game.Players:GetChildren()
randplayer = p[math.random(#p)]
randplayer.TeamColor = BrickColor.new("Really red")
randplayer.Character:BreakJoints()
m = Instance.new("Hint")
m.Parent = workspace
m.Text = randplayer.Name.." was chosen as the Human! "
wait(3)
m.Parent = nil
h.Parent = workspace
h.Text = "Plushies! You have 10 minutes to survive!"
wait (5)
for _, plr in pairs(game.Players:GetChildren()) do
plr.Character.HumanoidRootPart.CFrame = game.Workspace.bluespawn.CFrame
end
h.Parent = nil
p.Character.HumanoidRootPart.CFrame = game.Workspace.redspawn.CFrame
hm = randplayer.Character.Humanoid
hm.MaxHealth=300
hm.Health=300
wait(600)
for i = 1,#p do
if p[i].TeamColor == BrickColor.new("Really red") then
p[i].TeamColor = BrickColor.new("Pearl")
end
end
h.Parent = workspace
h.Text = "End of game"
wait(4)
h.Text = "Get ready for the next game"
wait (4)
h.Parent = nil
end
Any working answer is appreciated!

1 comment
Okay first off I suggest you make your variables more concise in their purpose. Instead of doing "p" do "players". That just makes it more readable not only for other people, but for yourself as well.