Roblox marble movement freezes when using ApplyImpulse every frame

I’m trying to simulate marble physics using WASD. Right now, I am using :ApplyImpulse() and the Humanoid.MoveDirection every frame in order to move the marble. However, I suspect that doing this is the reason I freeze every couple of seconds. The video provided showcases the issue.

Here is the code:

local function _onCharacterAdded(character: Model)
	local humanoid = character:WaitForChild("Humanoid", 5) :: Humanoid
	humanoid.PlatformStand = true

	local hrp = character:WaitForChild("HumanoidRootPart", 5)
	local MarbleTemplate = workspace:WaitForChild("Marble")

	if not humanoid or not hrp then
		return
	end

	local cloneMarble = MarbleTemplate:Clone() :: BasePart
	cloneMarble.Parent = workspace
	cloneMarble.Name = Players:GetPlayerFromCharacter(character).Name
	cloneMarble.CFrame = hrp.CFrame

	local weld = Instance.new("WeldConstraint")
	weld.Part0 = cloneMarble
	weld.Part1 = hrp
	weld.Parent = cloneMarble

	local lastMoveDirection = Vector3.zero

	RunService.Heartbeat:Connect(function(dt) -- this is where the trouble starts
		local velocity = cloneMarble.AssemblyLinearVelocity
		local horizontalVelocity = Vector3.new(velocity.X, 0, velocity.Z)
		local speed = horizontalVelocity.Magnitude
		local moveDirection = humanoid.MoveDirection
		local t = math.clamp(1 - speed / MaxSpeed, 0, 1)

		if moveDirection.Magnitude == 0 then
			lastMoveDirection = moveDirection.Unit
		end

		if lastMoveDirection.Magnitude == 0 then
			return
		end

		local impulse = moveDirection * Acceleration * dt * cloneMarble.AssemblyMass * t

		cloneMarble:ApplyImpluse(impulse)
	end)
end 

Help is appreciated!

I’m not entirely sure because I’m not the best with networking but I imagine because there are physics updates from both the server and client the network ownership has to do with it. I would try setting manually setting the network owner of the assembly.