codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
|
| 22 Jul 2016 01:33 PM |
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)
|
|
|
| Report Abuse |
|
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
|
| 22 Jul 2016 01:38 PM |
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)
|
|
|
| Report Abuse |
|
|
|
| 22 Jul 2016 01:42 PM |
"if plr.Backpack:FindFirstChild('Springfield Rifle')('Scoped Kar98k')" "('Springfield Rifle')('Scoped Kar98k')"
Who taught you how to script? That shouldn't even work. This will though:
if plr.Backpack:FindFirstChild("Springfield Rifle")["Scoped Kar98k"]
( ͡• ◡ ͡•) -=[ RAP: 368,330 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•) |
|
|
| Report Abuse |
|
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
| |
|
|
| 22 Jul 2016 01:45 PM |
Well, fix your code then. If you're trying to find an object inside something, it's done like this:
game.Workspace:FindFirstChild("Object")["Handle"]
OR
game.Workspace:FindFirstChild("Object").Handle
( ͡• ◡ ͡•) -=[ RAP: 368,331 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•) |
|
|
| Report Abuse |
|
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
|
| 22 Jul 2016 01:58 PM |
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)
|
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 22 Jul 2016 02:00 PM |
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. |
|
|
| Report Abuse |
|
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
|
| 22 Jul 2016 02:07 PM |
| 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 |
|
|
| Report Abuse |
|
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
| |
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
|
| 22 Jul 2016 02:14 PM |
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) |
|
|
| Report Abuse |
|
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
| |
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
|
| 22 Jul 2016 02:22 PM |
would there be a easier way to do this>
|
|
|
| Report Abuse |
|
|
codboy22
|
  |
| Joined: 05 May 2012 |
| Total Posts: 598 |
|
|
| 22 Jul 2016 02:41 PM |
that moment when your other script works, but the other doesn't https://www.youtube.com/watch?v=qBtO9Jk6Uck |
|
|
| Report Abuse |
|
|