Hello there, I’m working on a spawn animation where when your character spawns, it’ll play an animation and during the animation I want all the parts of the character to simultaneously fade in.
Here is my attempt at creating this effect:
– I created a function with the idea that I can run it as many times as I want so it will fade all at once.
local function fade(part)
for i = 1,0,-0.1 do
part.Transparency = i
wait(0.01)
end
end
Here is the rest of the code:
for i,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
if v.Name ~= "HumanoidRootPart" then
fade(v)
end
end
end
Right before this I play the animation, which is around 3 - 4 seconds long. And the animation plays fine.
you should use tweenservice, a much nicer way to do it
local TS = game:GetService("TweenService")
local TI = TweenInfo.new(Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 1)
for i,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
if v.Name ~= "HumanoidRootPart" then
TS:Create(v, TI, {Transparency = 1})
end
end
end
There were a couple things wrong with your code, but I fixed it. Yet it still didn’t work. My character just stayed invisible. No errors in the output.
EDIT: I searched up API and apparently Transparency cannot be tweened? is this correct?
Transparency is recognized as number value in roblox. Property name is just a way to access the data type. Part.Position is not saved as a data type Position, Part.Position is a reference to a Vector3 stored in memory.