This sounds really confusing and long but hear me out. I don't know how to fix this and it's literally been such a pain that i'm not sure if its a bug with a script or with studio itself. In a script that fades the screen to black then normal again using a black screen GUI (Activated with a Proximity Prompt), I'm trying to identify the frame in the local player's Gui. Easy, right? NAH. That's the entire issue. When running the game, you can indeed find the ScreenGui in the PlayerGui, but the script keeps giving outputs for "Frame is not a valid member of "BlackScreen" or "Infinite Yield possible on 'BlackScreen:WaitForChild("Frame")
I'm running out of options because there aren't any reasons that I can think of as to why this won't work. I'm still somewhat new to scripting, so if I missed anything, or I did something wrong that could be causing this issue, please let me know.
#Frame not being found in script while placement in Explorer is fine. Unsure of what the error is.
1 messages · Page 1 of 1 (latest)
Are you still stuck on this issue? can you try printing out something like
for _, v in blkscreen:GetChildren() do
print(v)
end
Hi, yes when you use :WaitForChild(), it will be looking for when the child gets added. So if it already exists, then it will not get added
since it doesnt get added, the WaitForChild() will never see it
i don't think that's true, it checks for the instance existing and if it doesn't find it it waits for the period of time specified by argument 2
try removing the type check
funny, that's also why it's an issue
when I remove it, it just says there ISNT a frame
"Frame is not a valid member of BlackScreen"
that's why I added the wait for child and it still doesn't work bc the system isn't identifying the frame
it still didn't work before I added the type check I already tried that
it is true
you know what I deadass might actually have to script an Instance.new() to make a new frame I didn't even think of that until like just now
that could actually work
https://create.roblox.com/docs/reference/engine/classes/Instance#WaitForChild
scroll slightly down to notes, and read the 1st note. If the child already exists, it will yield forever
if this works I'll be kinda annoyed bc I've been tryna fix this for like
a week or two
But yeah using "Wait for Child" is good when you know its not there yet, but is on its way. And if you do WaitForChild on a model, then you dont need to do it on the model's children. Cause it loads in the children before the model group itself
you just automatically avoid this issue with module scripts due to the parent script having to boot up first, and then run the modulescript, giving time for the other stuff to load in
But yeah if it says "infiniteYield" possible, it means the child "Frame" already existed when you did WaitForChild
Also if you got "Frame is not a valid member of BlackScreen" it probably means you did this:
BlackScreen.Frame
which is reserved for properties and methods for BlackScreen iirc. Instead try
BlackScreen:FindFirstChild() or something
turns it into nil
It does identify it but then it says like
Something along the lines of "tried finding material for Frame, got nil"
or something like that idk
did it say which line?
also did you try FindFirstChild() on blackscreen too? cause when you get the GUI then all of the gui should be loaded in
yeah I remember it being the line that identified the frame
but before, I merged the frame and transparency lines so it was blkscreen.Frame.Transparency
or blkscreen:FindFirstChild("Frame").Transparency
Ill just make a gui and test it myself
this worked for me
guiScript
local guiSystem = {}
local players = game:GetService("Players")
local lp = players.LocalPlayer
local gui = lp.PlayerGui
local blackScreen = gui:FindFirstChild("BlackScreen")
local frame = blackScreen:FindFirstChild("Frame")
function guiSystem.begin()
for i=1,10 do
frame.Transparency+=-0.1
task.wait(1)
end
end
return guiSystem
Video of it working. So it seems like its working fine on my end
perhaps would be very helpful to then know the name of your script, and where it is located, and where it is used if its a modulescript
that's not what it says? it says if the child already exists it will not yield
see also
name. If the child does not exist, it will yield the current thread until it does. If the timeOut parameter is specified, this method will time out after the specified number of seconds and return nil.
blackscreen.frame is also perfectly acceptable to find a child frame of parent blackscreen
sweet
anyways somehow works for me
i can't be any more honest
i'm completely lost
as you can see i made an Instance.New()
and the black screen in question isnt even appearing
the weirdest part is that there are literally 0 errors
is it because it's a localscript and not a script that the instance wont get added to the local players playergui
You should add print statements so its easier to debug. E.g. put one at the start of Triggered function like
print("Proximity Triggered")
then later some info like
if frame then
print("Frame exists")
end
Im trying my best to replicate it, but for me the gui script just works so i think it might be the prox
no. localscript is the only place localplayer exist. On non-localscripts it doesnt exist