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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Weapon Ammo

Previous Thread :: Next Thread 
dude6354 is not online. dude6354
Joined: 04 Apr 2009
Total Posts: 205
01 Oct 2012 06:24 PM
Hey, ive made a previous post on this but i have updated my script and i know im on the right track though. Problem is, im still getting an error. It says "Argument 1 missing or nil" please help!

Here is the code:


function onClick(player)

local playername = player.Name

local human = game.Players:findFirstChild(playername)

local gun = human.Backpack:findFirstChild(M14)

if gun ~= nil then

gun.AmmoLeft.Value = gun.AmmoLeft.Value +16

script.Parent.Parent:Remove()

end

end


script.Parent.ClickDetector.MouseClick:connect(onClick)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
01 Oct 2012 06:26 PM
playername and human are pretty much useless, as you already have the player object. And assuming "M14" isn't a variable, put it in quotes to make it a string.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
dude6354 is not online. dude6354
Joined: 04 Apr 2009
Total Posts: 205
01 Oct 2012 08:02 PM
i put the M14 in quotes and it says: "The Parent property of Workspace is locked"
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
01 Oct 2012 08:09 PM
Since your script doesn't even mention workspace, i'm going to guess it's a different script?

¤ ¤ † K M X D † ¤ ¤
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
01 Oct 2012 08:10 PM
Wait, script.Parent.Parent might be Workspace, what're you trying to remove?

¤ ¤ † K M X D † ¤ ¤
Report Abuse
dude6354 is not online. dude6354
Joined: 04 Apr 2009
Total Posts: 205
01 Oct 2012 08:15 PM
Oh! of course! it must be script.Parent! Thank you! It works now! I appreciate your help! :)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
01 Oct 2012 08:18 PM
No problem, happy to help.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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