#fade in function
1 messages · Page 1 of 1 (latest)
--true means in, false means out
local function fade(frame: Frame, state: boolean)
assert(frame:IsA("Frame"), `Expected {frame} to be a Frame.`)
--type(state) doesnt work so hardcode it into true or false
assert((state == true) or (state == false), `Expected {state} to be a boolean.`)
local tweens: {[number]: Tween} = {}
local fadePreferences: TweenInfo = state and fadeInPreferences or fadeOutPreferences
local validInstances: {[number]: {["instance"]: any, ["property"]: string | number}} = {}
for _, miniFolder in pairs(frame:GetChildren()) do
if not miniFolder:IsA("Folder") then
warn(`Expected {miniFolder} to be a Folder.`)
continue
end
for _, gui in pairs(miniFolder:GetChildren()) do
if not gui:IsA("GuiObject") then
warn(`Expected {gui} to be a GUI.`)
continue
end
--save and reset the old data
local goals: {[string]: any} = {}
--determine goals based on the gui's type
if gui:IsA("ImageLabel") then
if state then --fade in
goals.ImageTransparency = gui.ImageTransparency
gui.ImageTransparency = 1
else --fade out
goals.ImageTransparency = 1
table.insert(validInstances, {["instance"] = gui, ["property"] = "ImageTransparency"})
end
--yes i copy pasted this
elseif gui:IsA("ImageButton") then
gui.Interactable = state
if state then --fade in
goals.ImageTransparency = gui.ImageTransparency
gui.ImageTransparency = 1
else --fade out
```
goals.ImageTransparency = 1
table.insert(validInstances, {["instance"] = gui, ["property"] = "ImageTransparency"})
end
elseif gui:IsA("TextLabel") then
if state then --fade in
goals.TextTransparency = gui.TextTransparency
gui.TextTransparency = 1
else --fade out
goals.TextTransparency = 1
table.insert(validInstances, {["instance"] = gui, ["property"] = "TextTransparency"})
end
--yes i copy pasted this
elseif gui:IsA("TextButton") then
gui.Interactable = state
if state then --fade in
goals.TextTransparency = gui.TextTransparency
gui.TextTransparency = 1
else --fade out
goals.TextTransparency = 1
table.insert(validInstances, {["instance"] = gui, ["property"] = "TextTransparency"})
end
end
table.insert(tweens, TweenService:Create(gui, fadePreferences, goals))
end
end
--play the tweens
if state then
frame.Visible = true
for _, tween in pairs(tweens) do tween:Play() end
else
for _, tween in pairs(tweens) do tween:Play() end
task.wait(fadePreferences.Time)
frame.Visible = false
--reset everything back
for _, touple in ipairs(validInstances) do touple.instance:ResetPropertyToDefault(touple.property) end
end
end```
i'm using !strict so i have to be explicit, sorry for the huge block
use case:
i'd say that it has an ~85% to not bug when used
also, if it does happen to bug, the viewports stay visible
it's only bugging when fading in
but that's not the problem
can we ignore the asserts
there's no error messages so it's not the assert
also thanks for stopping to try to help
do you have any other idea on why this doesnt work
all the other functions do what they're supposed to do but nothing else is affected when the fade function doesn't work
so i should add runservice.rendersrtepped s?
nah what I mean is maybe ur tryna call it too fast

does it ever do it on first fade in
dammit
it could
it's about that 85% thing
it's not bugging on some specific numbers
I'll add in a renderstepped wait before fading them in
what
nah
what I mean is
well
Hm
task.wait is basically the same as renderstepped:wait
btw
ill go with the more precise one
if im using !strict, i might aswell
strict is just for type checking
im using strict with the purpose of torturing myself
attempt 1/1 worked
2/2 worked
3/3
4th didnt work
what other ideas do you have
i could screenshare if that'd help you
do you have any other ideas
i'm using it in a way to torture myself
gui is evil
😔
bro
idk if ur firing a remote to client to start
or what
but maybe u start another one too soon after the last
and its still going