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

What is wrong with my script?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
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

Log in to vote
1
Answered by 10 years ago
plr = game.Players:WaitForChild("Character").Parent.Character.Humanoid
Ad
Log in to vote
-2
Answered by
KAAK82 16
10 years ago

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

0
I got an error. Workspace.Map_Changer:93: attempt to index field 'Character' (a nil value) FamousDoge 0 — 10y
0
yes... thats wat I mean u didnt define plr... and who Thumbs Down on my Answer, is a Diphole! am saying the Answer! KAAK82 16 — 10y
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? KAAK82 16 — 10y
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! KAAK82 16 — 10y

Answer this question