Memory not decreasing ingame?

I have been having an issue with lag ingame and the cause is the memory that increases over time.
Whenever i try replicating this in studio the memory doesn’t get increased.
Ingame :


Studio :

What is causing this to happen??

local debris = game:GetService("Debris")
local isfiring = {}
Remotes.SpitFire.OnServerEvent:Connect(function(player,block,value)
	if isarena == true and block ~= nil and string.match(block:GetFullName(),player.Name) then
		if isarena == true and value ~= nil then
			if isfiring[block] == nil and value == true and block:FindFirstChild("Decorate") then
				isfiring[block] = true
				Remotes.Particles:FireAllClients(block.Decorate)
				repeat
					--pcall(function()
						if block.Decorate.Decor1.VelocityInheritance == 1 and block.Decorate.RotVelocity.Magnitude > 8 then
							block.Decorate.Decor1.VelocityInheritance = 0
						elseif block.Decorate.Decor1.VelocityInheritance == 0 and block.Decorate.RotVelocity.Magnitude < 6.5 then
							block.Decorate.Decor1.VelocityInheritance = 1
						end
						local newpart = Instance.new("Part")
						local vectorforce = Instance.new("VectorForce")
						local vectorforce2 = Instance.new("VectorForce")
						local attachment = Instance.new("Attachment")
						debris:AddItem(newpart,2.75)
						attachment.Parent = newpart
						newpart.CanCollide = false
						newpart.Transparency = 1
						vectorforce.Attachment0 = attachment
						vectorforce2.Attachment0 = attachment
						newpart.CFrame = block.Decorate.CFrame
						vectorforce.Force = Vector3.new(1000,0,0)
						vectorforce2.Force = Vector3.new(0,50250,0)
						vectorforce2.RelativeTo = "World"
						vectorforce.Parent = newpart
						vectorforce2.Parent = newpart
						newpart.Velocity = (block.Decorate.Velocity - block.Decorate.RotVelocity) + (block.Decorate.CFrame.RightVector * 49)
						newpart.Size = Vector3.new(7.5,7.5,7.5)
						newpart.Parent = block.Parent -- Aircraft
						newpart.Name = "SpittedLava"
						newpart:SetNetworkOwner(player)
					--end)
					wait(0.2)
				until not block or isfiring[block] == nil or not player
				if block and block:FindFirstChild("Decorate") and player then
					Remotes.Particles:FireAllClients(block.Decorate,nil,nil,false)
				end
			elseif isfiring[block] == true and value == false then
				isfiring[block] = nil
			end
		end
	end
end)

This topic was automatically closed after 1 minute. New replies are no longer allowed.