Hi there, I am working on optimising my scripts and recently took a look at my weapon scripts. From what I isolated and testing I found that when I shoot remotes to server when I shoot my gun that the memory goes up but never goes back down even though I don’t use any arrays to store data so technically it should go back down upon finishing execution.
Events.Remotes.Weapons.Fireshot.OnServerEvent:Connect(function(plr)
local Gun = plr.Character:FindFirstChildOfClass('Tool')
if Gun == nil then return end
local CurrAmmo = Gun:GetAttribute('CurrentAmmo')
if CurrAmmo == nil or CurrAmmo <= 0 then return end
if Gun.Name == 'M1014' then
Gun:SetAttribute('CurrentAmmo', CurrAmmo - (1 / 8))
else
Gun:SetAttribute('CurrentAmmo', CurrAmmo - 1)
end
-- Code below increases the memory (without the remote event)
for i,v in pairs(game.Players:GetPlayers()) do
if v ~= plr then
--Remotes.Weapons.Fireshot:FireClient(v, Gun)
end
end
end)
Any help would be appreciated thanks!