Texture ID is not loading in script, however it can be fixed manually

Hello,

I’ve been developing random faces for my NPCs, however they are just not loading.

	for i = 1, unitCount do
		local clone
		if i == 1 then
			clone = generalTemplate:Clone()
		else
			clone = unitTemplate:Clone()
		end
		clone.Parent = regimentFolder
		
		clone:SetPrimaryPartCFrame(CFrame.new(spawnPoint.Position + Vector3.new(0, 50, 0)))

		local xOffset = (col - unitsPerRow / 2) * spacing + math.random(1, 9) / 10
		local zOffset = (row - unitsPerRow / 2) * spacing + math.random(1, 9) / 10

		local groundPos = getGroundPosition(clone)
		clone:SetPrimaryPartCFrame(CFrame.new(
			groundPos.X + xOffset,
			groundPos.Y,
			groundPos.Z + zOffset
			))

		local face = clone.Head:FindFirstChildWhichIsA("Decal")
		if face then
			face.Texture = "http://www.roblox.com/asset/?id=" .. tostring(Facesx[math.random(1, #Facesx)])
		end

		table.insert(regimentData.units, clone)

		if row == 0 then
			table.insert(regimentData.firstRow, clone)
		end

		if i == 1 then
			regimentData.general = clone
		end

		col += 1
		if col >= unitsPerRow then
			col = 0
			row += 1
		end
	end

In the code you can see clearly:

                local face = clone.Head:FindFirstChildWhichIsA("Decal")
		if face then
			face.Texture = "http://www.roblox.com/asset/?id=" .. tostring(Facesx[math.random(1, #Facesx)])
		end

This changes texture ID to one of these ids:

255827175,
277950647,
21311601,
150182378,
141728790

After joining, face will set to the expected asset ID, however it does not load and the head is faceless. To fix that issue, I have to go inside the properties tab, click on the Texture property and click enter to load it manually, it works then.

Evidence:

Expected behavior

I expect the script to load the face properly.

I got it,

the problem is the recieved ID is not Texture ID, it is asset ID. There is currently no way of getting texture id from asset id, so I had to do it manually.

I had to get texture id manually.

Is there a possibility of fixing this issue?

Thank you for the report. We’ll add this to our feature request backlog.

maybe try doing this

"rbxassetid://"..target texture id bla bla bla

Well as I specified before, this indeed fixes the issue, however its pretty complicated to get texture id of the faces. You have to get manually ids one after another when you load in the game.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.