CaelmDev
(Caelm)
February 11, 2023, 11:59pm
#1
Hey, I am scripting a plugin that features GUI, and when I want to define each frame. Every time I try to do that though, it doesn’t work. Here is the script:
I don’t know if I should just define the variables manually every single time, but if I have to I will.
On which line do you get this error exactly? We’d need a bit more info
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:10am
#3
WaitForChild
returns nil when a timeout is set, and the set amount of time has passed. Just ignore the timeout parameter, it’s optional.
1 Like
CaelmDev
(Caelm)
February 12, 2023, 12:10am
#4
Sorry about that, line 11
char
CaelmDev
(Caelm)
February 12, 2023, 12:11am
#5
Yes but when I do that it just says attmept to index nil with (the thing I’m trying to get)
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:14am
#6
Again, WaitForChild
returns nil when you set a timeout and the script has waited enough time. If 10 seconds passed, the variable gui
is just nil, non-existent, even if the object itself has been added 10 seconds after. Thus, running gui:WaitForChild()
or other functions means nil:WaitForChild()
, causing the error you mentioned.
Just do local gui = script:WaitForChild("mainGui")
without the timeout.
CaelmDev
(Caelm)
February 12, 2023, 12:17am
#7
Infinite yield possible on 'user_plugincode.lua.Script:WaitForChild("mainGui")' - Studio
Now this error is showing
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:17am
#8
This is expected behavior. You don’t have mainGui
under your script.
CaelmDev
(Caelm)
February 12, 2023, 12:18am
#9
Then how am I supposed to make the GUI show up? lets just continue in dms
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:19am
#10
Oh, you saved as .lua
I think. That’s a script file, not a Roblox model file. Try .rbxm
.
1 Like
CaelmDev
(Caelm)
February 12, 2023, 12:19am
#11
also I do have mainGui
under the script
CaelmDev
(Caelm)
February 12, 2023, 12:24am
#12
would i just have to publish it and it is still saying infinite yield on mainGui
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:26am
#13
The .rbxm
option can be found by saving it as a local plugin. If you want to publish, maybe try grouping it first.
CaelmDev
(Caelm)
February 12, 2023, 12:28am
#14
I wish it showed as an option but it isn’t.
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:29am
#15
There’s the Save as type dropdown menu. Click that, select .rbxm
. Merely adding the extension name won’t work unless you have “All types” selected.
CaelmDev
(Caelm)
February 12, 2023, 12:32am
#16
When I press the dropdown it does not show “all files” or “.rbxm” I can try doing it manually but I don’t know why its doing this
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:32am
#17
Hmm, that’s weird. Group (Ctrl+G) the script, save again, and see what happens.
CaelmDev
(Caelm)
February 12, 2023, 12:34am
#18
It isn’t showing the option to save as local plugin for a group (it’s faded)
this is what happened when i tried manually doing it
Y_VRN
(Y_VRNDLL)
February 12, 2023, 12:37am
#19
How did you group your script? The test model I have is valid:
CaelmDev
(Caelm)
February 12, 2023, 12:43am
#20
Ok I’ll try that (should I do that with the GUI?)