Is it normal for client memory usage to go up? I’m concerned. I was testing my game and it slowly went up by like 3mb per 6 sec and then it crashed around 30 minutes later. If so could it be caused by too many remote events being fired?
It shouldn’t go up that quickly or at all. You might have a memory leak in one of your client scripts.
This shouldn’t have an impact on memory.
this is the only active script? could this be it? its client sided.
task.wait(1)
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local char = Player.Character
local origRightS = char:WaitForChild("Torso"):WaitForChild("Right Shoulder").C0
local origLeftS = char:WaitForChild("Torso"):WaitForChild("Left Shoulder").C0
local m = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local IsEquipped = false
game:GetService("RunService").RenderStepped:Connect(function()
if IsEquipped == true then
if char.Torso:FindFirstChild("Right Shoulder") then
char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), 1.55, 0, 0) , 0.1)
end
if char.Torso:FindFirstChild("Left Shoulder") then
char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), -1.55, 0, 0) , 0.1)
end
else
if char.Torso:FindFirstChild("Right Shoulder") then
char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:lerp(origRightS, 0.1)
end
if char.Torso:FindFirstChild("Left Shoulder") then
char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:lerp(origLeftS, 0.1)
end
end
end)
char.ChildAdded:Connect(function()
for i,v in pairs(char:GetChildren()) do
if v:IsA("Tool") then
if v:FindFirstChild("HoldArmsStill") then
else
IsEquipped = true
end
end
end
end)
char.ChildRemoved:Connect(function(instance)
if instance:IsA("Tool") then
IsEquipped = false
end
end)
game.ReplicatedStorage.Look.OnClientEvent:Connect(function(PlrAgain, neckCFrame, RsCFrame, LsCFrame)
local Neck = PlrAgain.Character.Torso:FindFirstChild("Neck", true)
local Rs = PlrAgain.Character.Torso:FindFirstChild("Right Shoulder", true)
local Ls = PlrAgain.Character.Torso:FindFirstChild("Left Shoulder", true)
if Neck then
Neck.C0 = neckCFrame
end
if Rs then
Rs.C0 = RsCFrame
end
if Ls then
Ls.C0 = LsCFrame
end
end)
while task.wait(0.05) do
game.ReplicatedStorage.Look:FireServer(char.Torso["Neck"].C0, char.Torso["Right Shoulder"].C0, char.Torso["Left Shoulder"].C0)
end
Is this script in StarterCharcterScripts?
yeah, (character limitttt3423423432)
Yes this is the cause for the memory leak then, I’ll try to fix this real quick and optimize it.
Done I believe. Try this and see if the memory rises:
--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
--//Variables
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local Character = script.Parent
local origRightS = Character:WaitForChild("Torso"):WaitForChild("Right Shoulder").C0
local origLeftS = Character:WaitForChild("Torso"):WaitForChild("Left Shoulder").C0
--//Controls
local IsEquipped = false
local connection = nil
--//Functions
connection = RunService.RenderStepped:Connect(function()
if not LocalPlayer.Character then
connection:Disconnect()
return
end
if IsEquipped then
if Character.Torso:FindFirstChild("Right Shoulder") then
Character.Torso["Right Shoulder"].C0 = Character.Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, .65, 0) * CFrame.Angles(-math.asin((Mouse.Origin.Position - Mouse.Hit.Position).unit.y), 1.55, 0, 0) , 0.1)
end
if Character.Torso:FindFirstChild("Left Shoulder") then
Character.Torso["Left Shoulder"].C0 = Character.Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, .65, 0) * CFrame.Angles(-math.asin((Mouse.Origin.Position - Mouse.Hit.Position).unit.y), -1.55, 0, 0) , 0.1)
end
else
if Character.Torso:FindFirstChild("Right Shoulder") then
Character.Torso["Right Shoulder"].C0 = Character.Torso["Right Shoulder"].C0:lerp(origRightS, 0.1)
end
if Character.Torso:FindFirstChild("Left Shoulder") then
Character.Torso["Left Shoulder"].C0 = Character.Torso["Left Shoulder"].C0:lerp(origLeftS, 0.1)
end
end
end)
Character.ChildAdded:Connect(function()
for i,v in pairs(Character:GetChildren()) do
if v:IsA("Tool") and not v:FindFirstChild("HoldArmsStill") then
IsEquipped = true
end
end
end)
Character.ChildRemoved:Connect(function(instance)
if instance:IsA("Tool") then
IsEquipped = false
end
end)
ReplicatedStorage.Look.OnClientEvent:Connect(function(PlrAgain, neckCFrame, RsCFrame, LsCFrame)
local Neck = PlrAgain.Character.Torso:FindFirstChild("Neck", true)
local Rs = PlrAgain.Character.Torso:FindFirstChild("Right Shoulder", true)
local Ls = PlrAgain.Character.Torso:FindFirstChild("Left Shoulder", true)
if Neck then
Neck.C0 = neckCFrame
end
if Rs then
Rs.C0 = RsCFrame
end
if Ls then
Ls.C0 = LsCFrame
end
end)
while LocalPlayer.Character and task.wait(0.05) do
ReplicatedStorage.Look:FireServer(Character.Torso["Neck"].C0, Character.Torso["Right Shoulder"].C0, Character.Torso["Left Shoulder"].C0)
end
It still rises? Could it be the remote event it fires?
No, the remote event doesn’t create anything that would take up space in memory. You could test this yourself in a script that just fires a remote event over and over.
actually it cant be arm rotation because when i disable it it still goes up
i am going crazy
What happens if you disable the script then try running your game?
it will still continue to go up
Are there any non-disabled scripts in your game? You can find them by typing “script” in the search bar inside of the explorer.
could this be one?
wait(2)
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local gun = script.Parent
local recoilstats = 1
local Camera = workspace.CurrentCamera
local equipped = false
local shooting = false
local debounce = false
local Up = false
--recoil
function RecoilShove()
local Recoil = 0.71415962
local recoilUpdate = CFrame.Angles(Recoil,0,0)
local recoilUpdateDown = CFrame.Angles(-Recoil,0,0)
Camera.CoordinateFrame = Camera.CoordinateFrame:Lerp(Camera.CFrame * recoilUpdate, 0.1)
spawn(function()
wait(.15)
Camera.CoordinateFrame = Camera.CoordinateFrame:Lerp(Camera.CFrame * recoilUpdateDown, 0.)
end)
end
gun.Activated:Connect(function()
local Connection
local function StartFiring(Input, Chatted)
if Chatted then
return
end
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
shooting = true
end
end
UIS.InputEnded:Connect(function(Input, Chatted)
if Chatted then
return
end
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
shooting = false
Connection:Disconnect()
end
end)
Connection = UIS.InputBegan:Connect(StartFiring)
end)
local players = game:GetService('Players')
local character = players.LocalPlayer.Character or players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')
local animator = humanoid:FindFirstChild('Animator') or Instance.new('Animator') -- you want to use an animator as using :LoadAnimation on the humanoid is deprecated
animator.Parent = humanoid
local shoot = animator:LoadAnimation(script.Parent:WaitForChild("Shoot"))
gun.Unequipped:Connect(function()
shooting = false
end)
while true do
if script.Parent.Reloading.Value == false then
if shooting == true then
if script.Parent.Stats.Ammo.Value <=0 and script.Parent.CTRL.CantRelWhileIntro.Value == false then
print("Can not fire, ammo is nil")
elseif script.Parent.Stats.Ammo.Value >0 and script.Parent.CTRL.CantRelWhileIntro.Value == false then
shoot:Play()
print("Can fire, ammo is not nil")
script.Parent.CTRL.FS:FireServer(mouse.Hit.Position)
script.Parent.Muzzle.FlashFire:FireServer()
debounce = true
local bullethole = game.ReplicatedStorage:WaitForChild("BulletHole"):Clone()
bullethole.Parent = game.Workspace
bullethole.Position = mouse.Hit.Position
RecoilShove()
wait(.08)
bullethole:Destroy()
end
end
end
debounce = false
RunService.RenderStepped:Wait()
end
most scripts are enabled???
I don’t think that would passively spike the memory but you are connecting 3 functions inside of one that will fire every time you activate the gun
you don’t need to run the shoot thing on renderstepped either, you can just connect it on a mouse click
Disable all the scripts in your game, enable one script at a time, test to see if they are affecting the memory usage in your game, disable that script you tested and repeat.
could while loops cause immense lag, even with task.wait(2) or something?