Coroutine or Lerp causing texture and color swapping on humanoids

Textures between multiple Humanoid characters get mixed up when continuously and concurrently changing the character’s appearance. This happens for both R6 and R15.

It looks like every time I change a character’s appearance, it creates a new texture which gets mistakenly used for a frame on other characters that are also changing their appearance at the same time.


This script is expected to make all parts of a character fade to black, it doesn’t set new textures to anything which leads me to believe this is a bug along with the fact that the position of the player camera changes which characters the glitch is happening to.

Happening to my self on Windows 10 PC, NVIDIA GeForce GTX 970 graphics card. Also affecting one other user and may have been happening for months, I’m not sure.

Simple repro: Repro.rbxl (30.8 KB)
More complex repro involving accessories: Repro 2.rbxl (61.1 KB)

Code for simple repro 1:
for i,v in pairs(workspace.Folder:GetChildren()) do
	for j,k in pairs(v:GetChildren()) do
		if k:IsA("BasePart") then
			
			spawn(function()
				while wait(0.1) do
					k.Color = Color3.new(k.Color.r-0.00001, k.Color.g-0.00001, k.Color.b-0.00001)
				end
			end)
			
		end
	end
end

Code for complex repro 2 (wont do anything without characters in a Characters folder in workplace):
--{Variables}--
local Color3Black = Color3.new(0,0,0)
local VertexBlack = Vector3.new(0,0,0)
local CharactersFolder = game.Workspace.Characters
local WaitTime = .1
local LoopIncrements =.005
--{Functions}--
    function AddStartingColor(Part,Color)
       
        if(Part:FindFirstChild("StartingColor") == nil) then
            if(typeof(Color) == "Color3") then
                local StartingColor = Instance.new("Color3Value")
                StartingColor.Value = Color
                StartingColor.Name = "StartingColor"
                StartingColor.Parent = Part
            else
                local StartingColor = Instance.new("Vector3Value")
                StartingColor.Value = Color
                StartingColor.Name = "StartingColor"
                StartingColor.Parent = Part
            end
 
        end
 
    end
     --[Lerp Base Part]--
    function LerpBasePart(BasePart)
        local StartingColor = BasePart.Color
        AddStartingColor(BasePart,StartingColor)
        --print("StartingColor:" .. tostring(StartingColor))
        for i=0,1,LoopIncrements do
            BasePart.Color = BasePart.StartingColor.Value:lerp(Color3Black,i)
            wait(WaitTime)
        end
    end
     --[Lerp Face]--
    function LerpFace(Face)
        for index,child in pairs(Face:GetChildren()) do
            if child:IsA("Decal") then
                local StartingColor = child.Color3
                AddStartingColor(child,StartingColor)
                for i=0,1,LoopIncrements do
                    child.Color3 = child.StartingColor.Value:lerp(Color3Black,i)
                    wait(WaitTime)
                end
            end
        end
    end
     --[Lerp Clothing]--
    function LerpClothing(Clothing)
        local StartingColor = Clothing.Color3
        AddStartingColor(Clothing,StartingColor)
        for i=0,1,LoopIncrements do
            Clothing.Color3 = Clothing.StartingColor.Value:lerp(Color3Black,i)
            wait(WaitTime)
        end
    end
     --[Lerp Accessories]--
    function LerpAccessories(Mesh)
        local StartingColor = Mesh.VertexColor
        AddStartingColor(Mesh,StartingColor)
        for i=0,1,LoopIncrements do
            Mesh.VertexColor = Mesh.StartingColor.Value:lerp(VertexBlack,i)
            wait(WaitTime)
        end
    end
       
     --[Lerp Characters]--
    function LerpCharacter(Character)
         --[Run LerpBaseParts + Clothing + Face Functions]--
        for index,variable in pairs(Character:GetChildren()) do
        --print(Character,": ",variable)
            if variable:IsA("BasePart") then
                 --[Run LerpBaseParts / Face Functions]--
                if not variable.Name == "Head" then
                    coroutine.wrap(LerpBasePart)(variable)
                else
                    coroutine.wrap(LerpBasePart)(variable)
                    coroutine.wrap(LerpFace)(variable)
                end
            elseif variable:IsA("Pants") or variable:IsA("Shirt") or variable:IsA("ShirtGraphic") then
                 --[Run LerpClothing Function]--
                coroutine.wrap(LerpClothing)(variable)
            end
        end
   
         --[Run LerpAccessories Function]--
        for index, accessory in pairs(Character.Humanoid:GetAccessories()) do
            for i, meshName in pairs(accessory:GetDescendants()) do
                if meshName:IsA("SpecialMesh") then
                    coroutine.wrap(LerpAccessories)(meshName)
                end
            end
        end
    end
   
 
wait(1)
 
 --{Get Characters}--
while true do
 
    for i,character in pairs(CharactersFolder:GetChildren()) do
        wait()
        coroutine.wrap(LerpCharacter)(character)
    end
    wait((1/LoopIncrements)*WaitTime+1)
end
print("Done")
9 Likes

Same issue is happening with me, and it happens randomly ingame for me. No clue as to why. I tried parenting all my NPC’s with different models. Nothing. It also affects players characters aswell.

1 Like

So I have a lot of NPC’s in my game, and I have had an issue for a while now where characters are switching clothes/color and also faces for a short amount of time and is an issue I wanted to address.

Here is a video of the bug occurring.

What I have noticed is that its happening when the character/players ingame character “updates” when I say update I mean change any sort of:

  • phyical appearence, whether it be adding, removing, or changing.

For instance in the video, the NPC changes right as it blinks. I have seen other people with this issue and I am hoping to have an update on this.

I have provided an example place here to show how this works: BugExample.rbxl (57.3 KB)