local c = game.Players:GetChildren() local r = math.random(1,game.Players.NumPlayers) local hum = plr.Character:WaitForChild("Humanoid") RANDOMPERSON = nil for i = 1,#c do if i == r then RANDOMPERSON = c[i] sword = game.Lighting.Sword5:Clone() sword.Parent = RANDOMPERSON.Backpack hum.WalkSpeed = 22 hum.Health = 250 end end
I got an error saying
Workspace.Map_Changer:93: attempt to index global 'plr' (a nil value)
plr = game.Players:WaitForChild("Character").Parent.Character.Humanoid
not
c = game.Players:GetChildreen()
but
plr = game.Players:GetPlayers()
or if u do c = game.Players:GetPlayers, then instead of typing plr use c cos u didn't define plr...