Trying to make a system where players can upload their uv map for a car in-game, players can then preview that UV map in-game on the vehicle. At the moment, when I upload the ID to the all the car meshes it turns to white instead of the actually uv map.
Now I heard that you got to convert it from asset ID to a texture ID, but got no clue how to achieve this and getting stuck.
Buttons.UploadButton.Button.MouseButton1Up:Connect(function()
local LiveryCode = LiveryCodeInput.Text
local assetId = tonumber(string.match(LiveryCode, "%d+"))
if not assetId then
ErrMsgSetup("Invalid Livery Code (must include a numeric asset ID).")
return
end
local success, info = pcall(MarketplaceService.GetProductInfo, MarketplaceService, assetId)
if not success or not info then
ErrMsgSetup("Failed to fetch asset info. Make sure it exists.")
return
end
local formattedId = "rbxassetid://" .. assetId
recentLiveryId = formattedId
Screens.MainFrame.Visible = false
Screens.UploadingFrame.Visible = true
local loadingCircle = Screens.UploadingFrame:WaitForChild("Loading_Circle")
local rotateConnection = RunService.RenderStepped:Connect(function(deltaTime)
loadingCircle.Rotation = loadingCircle.Rotation + 180 * deltaTime
if loadingCircle.Rotation >= 360 then
loadingCircle.Rotation -= 360
end
end)
task.spawn(function()
local bodies = {}
for _, bodyPart in ipairs(Car:GetDescendants()) do
if bodyPart:IsA("MeshPart") and bodyPart.Name == "Body" then
table.insert(bodies, bodyPart)
end
end
if #bodies == 0 then
rotateConnection:Disconnect()
Screens.UploadingFrame.Visible = false
Screens.MainFrame.Visible = true
ErrMsgSetup("No body parts found, contact support.")
return
end
for _, bodyPart in ipairs(bodies) do
bodyPart.TextureID = formattedId
end
task.wait(1)
rotateConnection:Disconnect()
Screens.UploadingFrame.Visible = false
Screens.MainFrame.Visible = true
ErrMsgSetup("Success! Livery applied to all body parts.")
end)
end)