EditableMeshes and UV Manipulation Help

I want to be able to scroll the UV’s so i can get a moving Texture but the issue i’m running into is that the UV’s are noisy when moving them unless its super slow. This doesnt seem to be an issue with the Trigs because I’ve tried with a cube and gotten the same result. If I used deltaTime the uvs wouldn’t move either.

–What I want to achieve is this smooth uv movement.
ezgif-3-e8fbeebd8f

–Current Issues and Iterations
ezgif-3-f661e4fd38
ezgif-3-f0b4808173

local EditableMesh = AssetService:CreateEditableMeshFromPartAsync(object)
EditableMesh.Parent = object

-- Get vertices and UVs
local Vertices = EditableMesh:GetVertices()
local UVs = {}

for _, vertex_id in ipairs(Vertices) do
	local uv = EditableMesh:GetUV(vertex_id)
	UVs[vertex_id] = uv
end

local speed = 0

RunService.RenderStepped:Connect(function(deltaTime)
	speed = script:GetAttribute("speed")

	-- Iterate over vertices and update UVs
	for _, vertex_id in ipairs(Vertices) do
		local uvPos = UVs[vertex_id]
		-- Modify UV position (example: adding time to X component)
		local newVector = uvPos + Vector2.new(speed * (uvPos.X + os.clock()), 0)

		-- Apply the new UV to the vertex
		EditableMesh:SetUV(vertex_id, newVector)
	end
end)

Try initiating os.clock() as a variable above the for loop. As far as I can recall, for loops do not run simultaneously and each iteration in a loop drives up execution time of a script, even on a micro level. Which would explain the ‘noise’ of your uv scrolling

This is likely a number precision error caused by os.clock() using big numbers.
Try replacing os.clock() by incrementing the delta UV in some other way, eg. using deltaTime.

Here is a reference repro file, try flipping the FIX_BUG = false variable to see the alternative way to implement this.

I hope that helps, let me know it works for you.

EditableMesh UV bug repro.rbxl (53.3 KB)