|
| 25 Nov 2012 10:25 PM |
I was working on a simple reload script for a pistol, there's nothing fancy, no animations.
Here's what I came up with:
local i = 1
local Tool = script.Parent local Ammo = Tool.Ammo local MaxAmmo = Ammo.Value
if Ammo.Value = 0 then Script.parent.Enabled = false
for i=1, 12 do wait(.1) Ammo.value = Ammo.value + 1 if Ammo.Value = 12 then script.Parent.Enabled = true end end
I'm not sure how to get this working, I used a loop for the the amount of ammo the pistol can hold.
I'm new to scripting so can someone point me in the right direction? |
|
|
| Report Abuse |
|
|
| |
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 26 Nov 2012 09:42 PM |
local Ammo = script.Parent.Ammo if Ammo.Value == 0 then -- == when in if statment. Script.Parent.Enabled = false for i = 1, 12 do wait(.1) Ammo.value = Ammo.value + 1 end script.Parent.Enabled = true end
This should work. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2012 08:10 PM |
I tried putting this into the tool but it didn't seem to work, the ammo went into the negatives.
Did I do something wrong?
|
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Nov 2012 06:31 PM |
if Ammo.Value = 0 then Script.parent.Enabled = false
Should be:
if Ammo.Value == 0 then script.Parent.Enabled = false |
|
|
| Report Abuse |
|
|
|
| 28 Nov 2012 06:32 PM |
| And why Ammo.Value +1? Don't you want the number to get smaller? |
|
|
| Report Abuse |
|
|