I’m doing a gun system. Has everything that I made. And I’m currently fixing bugs. This problem happens for many days. I checked what’s wrong and seeing that ReloadEvent:FireServer() doesn’t update the value.
Something like :
Reserve Ammo = 1000
Ammo capacity = 150
Current Ammo = 0
before reload the 2nd time:
Reserve Ammo = 850
Ammo capacity = 150
Current Ammo = 150
after reload the 2nd time:
Reserve Ammo = 850
Ammo capacity = 150
Current Ammo = 150
The problem is when i keep reloading. It doesn’t update the new reserve ammo and set current ammo to 150.
local function reloaded()
task.wait()
if tick() - reloadTick < time_reload then return end
isReloading = false
if reserve_ammoType.Value.Value > 0 then
ReloadEvent:FireServer(current_ammo,reserve_ammoType,ammo_capacity)
end
end
ServerScript :
script.Parent.ReloadEvent.OnServerEvent:Connect(function(player,ca,ra,ac)
ca.Value += ra.Value.Value
ra.Value.Value = (ca.Value - ac.Value)
ca.Value -= ra.Value.Value
if ra.Value.Value < 0 then
ca.Value += ra.Value.Value
ra.Value.Value = 0
end
end)
I’m kinda stuck on this problem for really long time and start to get stress. Anyone could help me about this problem?