I’m almost done with this script and I’ve been running into the same issue over and over again where I can only have one tween function properly within an in pair loops. If I add another tween, it manages to mess up the other. Here’s the code :
UIS.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == zflashkeybind then
anim:AdjustSpeed(0.6)
flashevent:FireServer()
hrp.Anchored = true
local Animation = TweenService:Create(hrp, info1, {["CFrame"]= hrp.CFrame + hrp.CFrame.LookVector * -35}):Play()
hrp.Anchored = false
for i, v in pairs(player.Character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal") then
local fadeOut = TweenService:Create(v, info2, {["Transparency"] = 1})
fadeOut:Play()
fadeOut.completed:Wait()
local fadeIn = TweenService:Create(v, info2, {["Transparency"] = 0})
fadeOut:Play()
end
end
end
end)
The goal is for the first tween (fadeOut) to turn the player invisible all at once, while the second tween (fadeIn) makes them visible again only after fadeOut is completed. I tested each tween and made sure they function by themselves, so they are not the problems. The problem seems to be using the In Pairs loop, it seems to not cooperate and makes it so that fadeOut turns the player transparent one component at a time (ex. their torso fades, then their head, then their arm, etc etc). Even afterwards, fadeIn doesn’t function - the player just remains invisible. Does anyone have an alternative solution or am I overlooking something?