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 » Scripting Helpers
Home Search
 

Re: simple pistol reload script

Previous Thread :: Next Thread 
TheLoneVaultDweller is not online. TheLoneVaultDweller
Joined: 22 Apr 2012
Total Posts: 18
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
justcallmedanny is not online. justcallmedanny
Joined: 22 Dec 2011
Total Posts: 81
26 Nov 2012 09:25 PM
any help?
Report Abuse
MrChubbs is not online. 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
TheLoneVaultDweller is not online. TheLoneVaultDweller
Joined: 22 Apr 2012
Total Posts: 18
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
TheLoneVaultDweller is not online. TheLoneVaultDweller
Joined: 22 Apr 2012
Total Posts: 18
28 Nov 2012 06:21 PM
Any help?
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
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
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
28 Nov 2012 06:32 PM
And why Ammo.Value +1? Don't you want the number to get smaller?
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