I have a server script which clones a GUI and parents it to PlayerGui.
However, the localscripts in the GUI seem to be starting before the GUI has actually loaded. I have the following code:
task.wait(1)
script.Parent.Visible = true
and am getting the following error:
Players.jackjenningsdev.PlayerGui.EagleGui.LegislationFrame.VotingFrame.VoteYea.LocalScript:2: attempt to index nil with ‘Visible’
Obviously this is confusing because “script.Parent” shouldn’t be nil, especially when the error indicates a path for the script that has a parent!
I have even tried adding task.wait(1) to the very start to delay the localscript’s execution to avoid this error… but no such luck.
The longer I extend the task.wait the more frequently it works, but it’s not a guarantee, and either way - waiting ~3-5 seconds before the GUI can take input isn’t a viable option.
why not just use serverscript just to make it visible
or
you can do this by disabling localscript by default then
use a serverscript to detect propertychanged signal
if parent is the GUI then enable the localscript
i know that’s a roundabout but it achieves your goal atleast