codboy22Join Date: 2012-05-05 Post Count: 598 |
19:31:43.582 - Players.codboy22.PlayerGui.Team Select.TEST.LocalScript:3: attempt to call a nil value
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
if plr.Backpack:FindFirstChild('Springfield Rifle')('Scoped Kar98k') or plr.StarterGear:FindFirstChild('Springfield Rifle')('Scoped Kar98k') or game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle')('Scoped Kar98k') then
if plr.Backpack:FindFirstChild('Springfield Rifle')('Scoped Kar98k') then
plr.Backpack:FindFirstChild('Springfield Rifle')('Scoped Kar98k'):Destroy()
end
if plr.StarterGear:FindFirstChild('Springfield Rifle')('Scoped Kar98k') then
plr.StarterGear:FindFirstChild('Springfield Rifle')('Scoped Kar98k'):Destroy()
end
if game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle')('Scoped Kar98k') then
game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle')('Scoped Kar98k'):Destroy()
wait(0.02)
end
end
plr.TeamColor = BrickColor.new('Liy white')
game.Workspace[plr.Name].Head:Destroy()
end)
|
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
2nd attempt
(same error)
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
if plr.Backpack:FindFirstChild('Springfield Rifle') or ('Scoped Kar98k') or plr.StarterGear:FindFirstChild('Springfield Rifle') or ('Scoped Kar98k') or game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle') or ('Scoped Kar98k') then
if plr.Backpack:FindFirstChild('Springfield Rifle') or ('Scoped Kar98k') then
plr.Backpack:FindFirstChild('Springfield Rifle')('Scoped Kar98k'):Destroy()
end
if plr.StarterGear:FindFirstChild('Springfield Rifle') or ('Scoped Kar98k') then
plr.StarterGear:FindFirstChild('Springfield Rifle')('Scoped Kar98k'):Destroy()
end
if game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle') or ('Scoped Kar98k') then
game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle')('Scoped Kar98k'):Destroy()
wait(0.02)
end
end
plr.TeamColor = BrickColor.new('Liy white')
game.Workspace[plr.Name].Head:Destroy()
end)
|
|
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
self learn't |
|
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
19:55:30.230 - Players.codboy22.PlayerGui.Team Select.TEST.LocalScript:3: attempt to index a nil value
same error, but with index in it!
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
if plr.Backpack:FindFirstChild("Springfield Rifle")["Scoped Kar98k"] or plr.StarterGear:FindFirstChild("Springfield Rifle")["Scoped Kar98k"] or game.Workspace[plr.Name]:FindFirstChild("Springfield Rifle")["Scoped Kar98k"] then
if plr.Backpack:FindFirstChild("Springfield Rifle")["Scoped Kar98k"] then
plr.Backpack:FindFirstChild("Springfield Rifle")["Scoped Kar98k"]:Destroy()
end
if plr.StarterGear:FindFirstChild("Springfield Rifle")["Scoped Kar98k"] then
plr.StarterGear:FindFirstChild("Springfield Rifle")["Scoped Kar98k"]:Destroy()
end
if game.Workspace[plr.Name]:FindFirstChild("Springfield Rifle")["Scoped Kar98k"] then
game.Workspace[plr.Name]:FindFirstChild("Springfield Rifle")["Scoped Kar98k"]:Destroy()
wait(0.02)
end
end
plr.TeamColor = BrickColor.new('Lily white')
game.Workspace[plr.Name].Head:Destroy()
end)
|
|
koolsJoin Date: 2009-01-11 Post Count: 1659 |
Springfield Rifle doesn't exist. That's why it is complaining about indexing a nil value.
[this] indexes something. Make sure that Springfield Rifle exists. |
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
im trying to destroy any weapons they carry when entering the lobby, but i can only do one weapon, hence this attempted script, which utterly failured |
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
failed* |
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
for example. this is will work for removing the britsh side gun
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
if plr.Backpack:FindFirstChild('Springfield Rifle') or plr.StarterGear:FindFirstChild('Springfield Rifle') or game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle') then
if plr.Backpack:FindFirstChild('Springfield Rifle') then
plr.Backpack:FindFirstChild('Springfield Rifle'):Destroy()
end
if plr.StarterGear:FindFirstChild('Springfield Rifle') then
plr.StarterGear:FindFirstChild('Springfield Rifle'):Destroy()
end
if game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle') then
game.Workspace[plr.Name]:FindFirstChild('Springfield Rifle'):Destroy()
end
end
plr.TeamColor = BrickColor.new('Lily White')
game.Workspace[plr.Name].Head:Destroy()
end) |
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
british* |
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
would there be a easier way to do this>
|
|
codboy22Join Date: 2012-05-05 Post Count: 598 |
that moment when your other script works, but the other doesn't
https://www.youtube.com/watch?v=qBtO9Jk6Uck |
|