Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to add an amount of numbers to a value within a tool in starterpack?

I'm trying to script a gun, When you find an ammo box and click on it ( I already have this part set up) It gives you the ammo in the box. Which, by default. Is 32 Bullets.

Also, I'm not sure which script type it is, however I believe it should be a localscript. I have tried this, And It has not worked (obviously)

I have researched values and changing them, otherwise, the main problem here is getting it to function properly.


function ammoadditon
	game.StarterPack.Glock.string Ammo (0+30) then
end
	
end

Also, if you could, please do not apply any agression to my mistakes, I am a beginning scripter.

1 comment

0

I'm refering to using the script inside of a object, the ammo box, when clicked on, if the player has no ammo, it will add 35 to it.

1 answer

✓ Accepted answer

I don't know what "string" is, but if you are saving a players ammo value, it would be better to use an IntValue instance, or better yet, store it as a variable.

Anyways, to add X amount of bullets to your ammo, you simply do

game.StarterPack.Glock.Ammo.Value = game.StarterPack.Glock.Ammo.Value + AMOUNTHERE

1 comment

0

"Ammo" should be referenced locally, not from the StarterPack. But your definition syntax is correct :D

This discussion is preserved as it was. New answers, comments, and votes are closed.