It wouldn't be too bad, but using the event is much easier in addition to being lighter on resources.
Lua Code:
local function HideUI()
UIParent:Hide()
end
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_STOPPED_MOVING")
f:RegisterEvent("PLAYER_STARTED_MOVING")
f:SetScript("OnEvent", function(self, event)
if event == "PLAYER_STOPPED_MOVING" then
C_Timer.After(3, HideUI)
end
if event == "PLAYER_STARTED_MOVING" then
UIParent:Show()
end
end)