Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is the gui's children deleting when doing into Playergui?

I'm doing a check to see if someone has a shirt, and if they do clone a gui into the players gui.

but whenever I move it, it deletes the children..

Code

local Player = game.Players.LocalPlayer
local Items = {291002383,291002527,291002685,291003057,291004569,342437379}

local Owns = function()
	for i = 1, #Items do
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(Player, tonumber(Items[i])) then
				local gui = script.Guis.gui
				local CGui = gui:Clone()
				CGui.Parent = Player.PlayerGui
				print(CGui.Parent)
			return true
		end
	end
	return false
end

11:28:07.711 - Something unexpectedly tried to set the parent of gui to NULL while trying to set the parent of gui. Current parent is PlayerGui.

Help? If you need more of an explanation, please post a comment

1 answer

✓ Accepted answer

Replication

Roblox doesn't really like the LocalScripts trying to do stuff that it can't see. One of these issues is trying to parent new Instances from a LocalScript whilst replication is trying to work its way across the server. Result? Chaos.

You should try and wait a bit before moving the stuff into PlayerGui, so that it doesn't flip out. We had a similar problem when working with Valkyrie, so you're not alone. If FE isn't on, I would recommend using it, as it solves a lot of other issues and vulnerabilities when done properly, as well as encouraging good standards.

8 comments

0

Using a module script. ;)

0

It doesn't matter. A ModuleScript inherits the (used loosely) it's used from, and if that's a LocalScript then the ModuleScript is treated as a LocalScript.

0

How long should I wait then?

0

Not actually sure. c:

0

Our end solution for Valkyrie was to not move it to PlayerGui at all. We ended up with a weird solution for it.

0

Well, I need it in that on persons gui. What was the weird solution?

0

Not one that will work here. Where is script?

0

Well, the module script can't be moved or other scripts will break. I'll find another way. Weird that other guis work just fine moving but ok

This discussion is preserved as it was. New answers, comments, and votes are closed.