Hey! so im making a fade part function for my game and im stuck in a problem, the script is that the script isnt knowing that the time for the tween to apply is set by the function, i dont know if i explained right but you will understand the error at the script
Can anyone help me fix that?
The Script
local tweenservice = game:GetService("TweenService")
local tower = workspace.Tower
function fade(part, ftime, fcooldown)
local fadingpart = part
while true do
if fadingpart == nil then
print("Breaked lol")
break
end
local fadetime = tonumber(ftime) or 1
local fadecooldown = tonumber(fcooldown) or 0.5
--// The Lines with errors
local fadeout = tweenservice:Create(fadingpart, TweenInfo.new(fadetime, Enum.EasingStyle.Linear), {Transparency = 0.925})
local fadein = tweenservice:Create(fadingpart, TweenInfo.new(fadetime, Enum.EasingStyle.Linear), {Transparency = 0})
--//
fadeout:Play()
fadeout.Completed:Wait()
task.wait(fadecooldown)
fadein:Play()
fadein.Completed:Wait()
task.wait(fadecooldown)
end
end
for _,v in pairs(tower:GetDescendants()) do
if v:FindFirstChild("fadepart") then
coroutine.wrap(fade)(v, v.FTime, v.Cooldown)
end
end
tower.DescendantAdded:Connect(function(v)
if v:FindFirstChild("fadepart") then
coroutine.wrap(fade)(v, v.FTime, v.Cooldown)
end
end)
coroutine.wrap(fade)(workspace.FadingPart, workspace.FadingPart.FTime, workspace.FadingPart.Cooldown)