I was trying to make a ammo giver for my gun
It works when its first time you use the giver, but it wont work after first time using the giver untill i reset.
how can i fix this?
I can try to help, first of all, any errors?
Your ammo giver script will only work when the M16 is not equipped.
When a tool is equipped, it is reparented (moved) from the player’s backpack to the player’s character.
Therefore, “player.Backpack:FindFirstChild(“M16”)” will return nil when the tool is equipped and the ammo giver is activated, causing your code to break.
Try this instead:
local proxy = script.Parent:WaitForChild("ProximityPrompt")
proxy.Triggered:Connect(function(player)
if player.Backpack:FindFirstChild("M16") then --checks whether the M16 is in the backpack (unequipped)
player.Backpack.M16.Settings.ReserveAmmo.Value = 7
elseif player.Character:FindFirstChild("M16") then --checks whether the M16 is in the character (equipped)
player.Character.M16.Settings.ReserveAmmo.Value = 7
end
end)
there were no visible errors could be seen on f9
well it works when its equipped, but it still doesnt give ammo after using it first time
Did you reload? I’m not entirely sure how your gun works: I’m assuming that ReserveAmmo is the amount of ammo left that can be reloaded into the gun, and that Ammo is the amount of ammo ready to fire.