Uhh so i made an ammo pack script for turbofusion guns, works perfectly with the sniper rifle i made. The problem here is that it doesnt work with other weapons.
Output
19:05:18.937 - Humanoid is not a valid member of Tool
19:05:18.938 - Stack Begin
19:05:18.938 - Script 'Workspace.ammopile_SMG.GiveAmmo', Line 6
19:05:18.939 - Stack End
Script
local ammoPickup = 30 local bundleType = "SMG" local ammoLeft = 180 local canPickup = true script.Parent.Touched:connect(function(hit) if hit.Parent.Humanoid then --checks if hit.parent has an humanoid item local find = hit.Parent:FindFirstChildOfClass("Tool") --if it has one, it searches for a tool that he currently uses if find then local find2 = find:FindFirstChild("AmmoType") --then if he does, checks if this item has the AmmoType stringvalue if find2 then local find3 = find:FindFirstChild("Gun_Main") --if it does again, it searches for the Gun_Main localscript to determine if the tool is actually a gun (works with turbofusion kit only for now) if find3 then if find2.Value == bundleType then local find4 = find2.Parent:FindFirstChild("StoredAmmo") --searches for the StoredAmmo intvalue if find4 then if ammoLeft > 1 and canPickup == true then canPickup = false script.Parent.PickupSound:Play() find4.Value = find4.Value + ammoPickup ammoLeft = ammoLeft - ammoPickup wait(2) canPickup = true end end end end end end end end) while true do wait(0.1) if ammoLeft < 0 then ammoLeft = 0 end end
Please, do you know what's causing this? i do get ammo when i use the sniper rifle, but it spams my console when i try with the SMG.