generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Broken script

Previous Thread :: Next Thread 
codboy22 is not online. 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 is not online. 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
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
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 is not online. codboy22
Joined: 05 May 2012
Total Posts: 598
22 Jul 2016 01:44 PM
self learn't
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
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 is not online. 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 is not online. 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 is not online. 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 is not online. codboy22
Joined: 05 May 2012
Total Posts: 598
22 Jul 2016 02:08 PM
failed*
Report Abuse
codboy22 is not online. 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 is not online. codboy22
Joined: 05 May 2012
Total Posts: 598
22 Jul 2016 02:18 PM
british*
Report Abuse
codboy22 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image