FindFirstChild Returning As False, Even When True?

Hello, so my current script replicates itself to the playergui as long as it isn’t already in the playergui, and there isn’t already another duplicate of itself in there. However, when I check for the duplicated using findfirstchild, it always returns as nil.

if Gui.Parent ~= plr.PlayerGui then
	if plr.PlayerGui:FindFirstChild("CaptainChat") == nil then	
	Gui.Parent = plr.PlayerGui
	else
		Gui:Destroy()
	end
end

409651b13f008015d70bd143c01fe6bf
370391814f33b4633715f07473ecc169

1 Like

Is this a server script? A local script should be doing this if it isn’t already.

Also gyazo doesn’t work, you should embed it to the actual post

It’s not a server script, it’s a local script.

Oh alright. Local scripts in StarterGui are already cloned into the player’s PlayerGui, so why reinvent the wheel? I feel I am missing something here. What is it for?

It’s an NPC that speaks to the players. Putting in StarterGui wouldn’t be right, as the NPC doesn’t always speak with them. Currently the GUI is a child of StarterCharacter.

1 Like

Nevermind, in the first statement I meant to check if the gui was a parent of plr gui, but I was checking it as script.Parent which would always fire as nil because the script never is a parent of anything but the Gui. Not sure how affected the second statement at all but, It seems to be working fine now, will update if anything goes wrong.