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 my script?

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)

2 answers

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

4 comments

0

I got an error. Workspace.Map_Changer:93: attempt to index field 'Character' (a nil value)

0

yes... thats wat I mean u didnt define plr... and who Thumbs Down on my Answer, is a Diphole! am saying the Answer!

0

also... if u wondering y is it a problem... well cos if u didnt define plr then, how would the System know where to look for something... u get me?

0

another idiot that Thumbs Down, just, just NOOBS!!! I got no Words to say! Shame on all u Noobs! Idiots, first try this and try wat was in his Script! then Judge wether its a Fix or piece of Crap words! seriously! Idiots!

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