BillboardGui not cloning

Hello all

In my game there’s a script that clones a billboardgui which is parented to your head when you spawn. It was working a few days ago and now it is not. Idk what has changed since then and now but here we are.

I’ve looked through find/replace all and the only mention of my gui is in this script. I also have another script that removes accessories but I don’t think that’s contributing to the problem here. I have added print statements to see if maybe the code just ended prematurely but to no avail.

Anyways here’s the code

Player.CharacterAdded:Connect(function()
		print(1)
		local LevelGuiClone = ReplicatedStorage.VFX.LevelGui:Clone()
		LevelGuiClone.Parent = Player.Character.Head
		LevelGuiClone.Adornee = Player.Character.Head
		print(2)
		LevelGuiClone.LevelText.Text = tostring(game.ServerStorage[Player.Name]:FindFirstChild("Level").Value)
	end)

Try using :WaitForChild(‘Head’) instead of indexing with a period. Also player.CharacterAdded passes the newly created character to the function, so you could try using this instead of indexing through player.Character

I tried this as well as doing Player.Character:WaitForChild() but it’s still not working. It seems to not be cloning at all.

image

Are there any errors in the output? If not, could you send your full script?

No errors & it prints the numbers I’ve put in.

Okay, then it looks ok to me. Try using LevelGuiClone:WaitForChild(‘LevelText’), I find cloning can be a bit finicky

Also is there any chance you have something else in your character that’s called “head”?

Tried this, still not working.
Nothing else named head in my character.
image

I fear this may be a bug but I’m going to run some tests I guess. It could also be something else in my codebase interfering but I highly doubt, I’m going to find anything with the Destroy method or .Parent = nil and check though.

Here, Try this

Player.CharacterAdded:Connect(function(character)
		print(1)
		local LevelGuiClone = ReplicatedStorage.VFX:WaitForChild("LevelGui"):Clone()
	    LevelGuiClone.Parent = character:WaitForChild("Head")
	    LevelGuiClone.Adornee = character:WaitForChild("Head")
        LevelGuiClone.Enabled=true
		print(2)
		LevelGuiClone.LevelText.Text = tostring(game.ServerStorage:WaitForChild(Player.Name):FindFirstChild("Level").Value)
end)

Could you send your updated script?

Tried this, didn’t work. Prints 1 and 2.
image

Player.CharacterAdded:Connect(function(Character)
		print(1)
		local LevelGuiClone = ReplicatedStorage.VFX.LevelGui:Clone()
		LevelGuiClone.Parent = Character:WaitForChild("Head")
		print(2)
		LevelGuiClone:WaitForChild("LevelText").Text = tostring(game.ServerStorage[Player.Name]:FindFirstChild("Level").Value)
end)

Any warnings even? Like an infinite yield or something? Could you try printing the clone’s parent after you set it?

It appears that it gets deleted by something else in my game qq

is there any way to like hook(?) onto the destroy function and see where its originating from?

Not sure, I know you can hook into instance.Destroying but that wouldn’t print the stack trace. You could print :GetFullName and that would tell you where it’s moved to but again that only does so much. You could do a binary search with all of the scripts in your game maybe as a last resort if those 2 things don’t give you any leads?

Press ctrl+shift+f, Then type :Destroy() to find where it is destroying the BillboardGui

I’ve tried this already. I cant find anything that destroys it, which is why I find this so weird.

1 Like

can you show me the properties from the billboard gui?

And another thing, maybe this bug happens because the billboard appears before the player loads. If so, it would be right for the player to load first and then the billboard to appear.
Try it:

Player.CharacterAppearanceLoaded:Connect(function(character)
		local LevelGuiClone = ReplicatedStorage.VFX.LevelGui:Clone()
		LevelGuiClone.Parent = Character:WaitForChild("Head")
		LevelGuiClone:WaitForChild("LevelText").Text = tostring(game.ServerStorage[Player.Name]:FindFirstChild("Level").Value)
end)