Unboxing System (Walking Server Side?)

Hello Guys! I recently made this unbox opening system like in Unbox Simulator.

I wanted to know if player is still breaking box and if they walk box breaking gets cancelled.


function Update()
    --// Checking if players are walking
    spawn(function()
        while true do
            RunService.Heartbeat:Wait()
            for i,plr in pairs(game.Players:GetPlayers()) do
                if plr.Character and plr.Character.PrimaryPart then
                    if plr.Character.Humanoid.MoveDirection.Magnitude > 0 then
                        local tab = GetPlayer(plr.UserId)
                        if tab ~= nil then
                            tab.Moving = true
                            tab.Selected = nil
                        end
                    else
                        local tab = GetPlayer(plr.UserId)
                        if tab ~= nil then
                            tab.Moving = false
                        end
                    end
                end
            end
        end
    end)
end

Function to check walking of each player. This is server side. I want to know if this is a good idea or is this a bad idea?

In theory this should work fine, but I would recommend using a coroutine instead of spawn. Also when does “Update” get called?

function UnboxService:Start()
      Update()
end