How would I unlag this script

How would I unlag the following script? (localscript)

local player = game.Players.LocalPlayer
local uispart = Instance.new("Part", workspace)
uispart.Transparency = 0
uispart.Anchored = true
uispart.Size = Vector3.new(1,1,1)

while wait() do
	print("ready to move")
	uispart.Position = player.Character.HumanoidRootPart.Position + Vector3.new(2,0,2)
	print("moved")
end

Thanks for reading!

1 Like

For moving stuff I think it’s best to use the Lerping instead of Position + Vector 3. There are videos on YouTube about on making it look smooth

Instead of while wait() do you can use game:GetService("RunService).Heartbeat:Connect(function()) if you want something to happen every frame, which would be much smoother than using a while loop

If you are using the new “expressive output” - disable that feature and use the old one. The new one has performance issues when printing constantly.

1 Like

Thanks for the idea, I found the issue though, something with new version of output, deleting the prints fully unlagged it