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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 01 Oct 2012 08:18 PM |
No problem, happy to help.
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|