I am trying to refill my ammo through a remote event, it seems to find the items in the backpack but it doesn't get past "if backpackItems[i]:FindFirstChild("CanResupply")
Can anyone help out? Thanks!
script.Parent.Resupply.OnServerEvent:connect(function(Player,price)
print(Player)
print(price)
local cash = Player.leaderstats.Cash
local Mag = (script.Parent.Center.Position-Player.Character.HumanoidRootPart.Position).magnitude
local humanoid = Player.Character:WaitForChild("Humanoid")
local backpackItems = Player.Backpack:GetChildren()
for i = 1,#backpackItems do
print(backpackItems[i])
if backpackItems[i]:FindFirstChild("CanResupply") then
print(backpackItems[i].Name)
local configs = backpackItems[i]:WaitForChild("Configs")
local ammo = configs:WaitForChild("Ammo")
local magSize = configs:WaitForChild("MagSize")
local reserveAmmo = configs:WaitForChild("ReserveAmmo")
local maxResAmmo = configs:WaitForChild("MaxResAmmo")
if Mag <= script.Parent.Range.Value then
ammo.Value = magSize.Value
reserveAmmo.Value = maxResAmmo.Value
end
end
end
end)

1 comment
Nice