local ts = game:GetService("TweenService")
local tweens = {}
local function cleanup()
for _, tween in next, tweens, nil do
tween:Destroy()
end
end
--then:
for _, part in next, char:GetDescendants(), nil do
if not v:IsA("Part") and not v:IsA("MeshPart") then continue end
local tween = ts:Create(v, tweenInfo, {Transparency = 1})
tween:Play()
table.insert(tweens, tween)
end
cleanup()
These tweens would be destroyed as soon as the loop ends. Also, tweens remove themselves if there are no references to them when they finish.
TimeToTween = 3
local tweenInfo = TweenInfo.new(
TimeToTween ,
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
function MakeYouFade(Character)
--//I'd reccomend using a BodyMover constraint (like linearvelocity) instead of tweening the player upwards. But if you need to for whatever reason, you should anchor the rootpart first.
for i,v in ipairs(Character:GetDescendants()) do
if v:IsA("BasePart") then
--//Make parts invisible.
tween = TweenService:Create(char.HumanoidRootPart, tweenInfo, { Transparency = 1})
tween:Play()
end
end
task.wait(TimeToTween)
plr:LoadCharacter()
end
Oops, I forgot to wait the tween time. Thanks for the correction. Are you sure they remove themselves? I’ve used tweens and checked memory logs, etc. afterwards and they’ve still existed.
Thanks for the help, for some reason, the player doesn’t fade. Any ideas why?
local description = game:GetService("ServerStorage").GodlyCharacter
humanoid:ApplyDescriptionReset(description)
local TimeToTween = 3
local tweenInfo = TweenInfo.new(
TimeToTween ,
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local function MakeYouFade(Character)
--//I'd reccomend using a BodyMover constraint (like linearvelocity) instead of tweening the player upwards. But if you need to for whatever reason, you should anchor the rootpart first.
for i,v in ipairs(Character:GetDescendants()) do
if v:IsA("BasePart") then
--//Make parts invisible.
local tween = TweenService:Create(char.HumanoidRootPart, tweenInfo, { Transparency = 1})
tween:Play()
end
end
task.wait(TimeToTween)
plr:LoadCharacter()
end
local tween = TweenService:Create(char.HumanoidRootPart, tweenInfo, { Position = char.HumanoidRootPart.Position + Vector3.new(0, 10, 0) })
tween:Play()
MakeYouFade(char)
Edit: I was being stupid I just had to swap char.HumanoidRootPart for v. Thank you very much for your help its working perfectly
local description = game:GetService("ServerStorage").GodlyCharacter
humanoid:ApplyDescriptionReset(description)
local TimeToTween = 3
local tweenInfo = TweenInfo.new(
TimeToTween ,
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local function MakeYouFade(Character)
--//I'd reccomend using a BodyMover constraint (like linearvelocity) instead of tweening the player upwards. But if you need to for whatever reason, you should anchor the rootpart first.
for i,v in ipairs(Character:GetDescendants()) do
if v:IsA("BasePart") then
--//Make parts invisible.
local tween = TweenService:Create(v, tweenInfo, { Transparency = 1})
tween:Play()
end
end
task.wait(TimeToTween)
plr:LoadCharacter()
end
local tween = TweenService:Create(char.HumanoidRootPart, tweenInfo, { Position = char.HumanoidRootPart.Position + Vector3.new(0, 10, 0) })
tween:Play()
MakeYouFade(char)
EDIT: Nevermind, you figured it out on your own. Still, I’ll leave it here for anyone else needing this.