When tweening the characters’ transparencies to make them fade in and out, their clothes appear to be swapping and changing colour rapidly.
Video of issue:
Here’s the code I used to tween the characters’ transparencies:
local function fadeChar(char, fadeDirection)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
if fadeDirection == "In" then
for index, object in pairs(char:GetDescendants()) do
if object:IsA("BasePart") and object.Name ~= "HumanoidRootPart" or object:IsA("Decal") then
local tween = game:GetService("TweenService"):Create(object, tweenInfo, {Transparency = 0})
task.spawn(function()
tween:Play()
end)
end
end
elseif fadeDirection == "Out" then
for index, object in pairs(char:GetDescendants()) do
if object:IsA("BasePart") or object:IsA("Decal") then
local tween = game:GetService("TweenService"):Create(object, tweenInfo, {Transparency = 1})
task.spawn(function()
tween:Play()
end)
end
end
end
end
I used this same function in another module function without any issues so this is really weird. Also, if only one character is generated, I don’t get this issue.
Code snippet of code used to create characters from the player’s friends list:
local fanNumber1 = math.random(1, #currentPage)
local fanNumber2 = math.random(1, #currentPage)
local fanNumber3 = math.random(1, #currentPage)
local fanNumber4 = math.random(1, #currentPage)
for count = 1, #currentPage do
local userId = currentPage[count].Id
if count == fanNumber1 then
local charGen
local success = pcall(function()
charGen = game.Players:CreateHumanoidModelFromDescription(game.Players:GetHumanoidDescriptionFromUserId(userId), Enum.HumanoidRigType.R15)
end)
if not success then
charGen = game.Players:CreateHumanoidModelFromDescription(game.Players:GetHumanoidDescriptionFromUserId(player.userId), Enum.HumanoidRigType.R15)
end
table.insert(fanTab, charGen)
end
-- Etc
Code snippet of when the fade function is used:
for index, char in pairs(fanTab) do
fadeChar(char, "In")
task.spawn(function()
task.wait(4)
fadeChar(char, "Out")
task.wait(1.5)
char:Destroy()
end)
end
Any help is appreciated. Has anyone encountered this issue? Is it a bug? Does anyone know how to fix this? Thanks.