Can anyone explain this error, what it means, how to prevent it?
[The Parent property of FadeGui is locked, current parent: NULL, new parent PlayerGui]
local fadeGui = Instance.new("ScreenGui")
fadeGui.Name = "FadeGui"
fadeGui.DisplayOrder = 9
fadeGui.ResetOnSpawn = false
fadeGui.IgnoreGuiInset = true
function Fade:In()
fadeGui.Parent = PlayerGui
end
That appears to be a warning, rather than an error. Warnings do not cause any problems in the scripts.
After it was parented to nil for a long time, it is, as @colbert2677 previously stated, garbage collected. This means you have to fix this problem by parenting it directly to the PlayerGui upon instance creation and then use the Enabled property instead.
Toggle Enabled to true when in use. Default: false
Script Rewritten:
local fadeGui = Instance.new("ScreenGui")
fadeGui.Name = "FadeGui"
fadeGui.DisplayOrder = 9
fadeGui.Enabled = false
fadeGui.ResetOnSpawn = false
fadeGui.IgnoreGuiInset = true
fadeGui.Parent = PlayerGui
function Fade:In()
fadeGui.Enabled = true
end
I really don’t think it was garbage collected. Things get garbage collected when there are no references to that object and that function pretty clearly references it. Not to mention, you can still access the properties of that object.
Are you sure you didn’t destroy it? :Destroy() an object causes the Parent property to get locked.
Correct me if i’m wrong, but if the ScreenGui got garbage collected, it would disappear entirely, so trying to set .Parent on it would produce a nil value error, instead of saying that the Parent is locked.
The only possible cause which comes to my mind is that you’re trying to parent the same gui after it was Destroy()'ed due to the player respawning. Are you sure you don’t accidently do that?