Parent Property locked

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
2 Likes

Error Or…?


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
2 Likes

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.

2 Likes

Enable has no effect on the visibility of the gui. I think you meant to toggle the Visible property.

1 Like

You’re confused. This is a ScreenGui. ScreenGui | Documentation - Roblox Creator Hub

Toggles the visibility of the LayerCollector.

OH WAIT WHAT! DOCUMENTATION CONFUSED! WE NEED TO REPORT THIS IMMEDIATELY! Oh, and sorry for caps. I don’t know if that is correctly documented.

2 Likes

Nah, you’re right. I thought OP was using a frame for some reason.

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?

1 Like

I deleted the response because I already went ahead and tested this. Not sure why it was restored. May have been another post.

If it’s cleared from memory, yeah, it wouldn’t be accessible anymore.