Player head is getting deleted, and script is attempting to access the deleted head?

  1. What do you want to achieve?
    I am trying to access the players head so that I can adorn an overhead UI to it

  2. What is the issue?
    If the player has a non-default roblox head, their head will get deleted and re-added, causing my script to access the wrong head.

  3. What solutions have you tried so far?
    I have added a task.wait(1) delay in order to get the correct head, but I want to accomplish this without using a wait function.

Here is the code I am using right now to try and access the players head, I added comments to try and showcase what is happening.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Head").Destroying:Connect(function()
			print("head destroyed! character:WaitForChild(Head) links to the wrong head now.") --print statement is reached
		end)
		print(character:WaitForChild("Head").MeshId) -- 7430070993 (Default Roblox Head Mesh)
		task.wait(1)
		print(character.Head.MeshId) -- 4307559885 (Players correct Head Mesh)
	end)
end)

And for clarification, I do not have any scripts deleting the players head. This code still has the same output in a default baseplate if you have a head equipped that’s different from the default.

3 Likes

Why are you destroying the Head when all you want to change is the Mesh?
If you are worried about different sized heads and offsets you can change those as well to the default head settings.
It also won’t destroy the Neck weld, which kills the character (unless you have changed that setting in-game).

I am not destroying the head, roblox does that by default. All I am trying to do is access the players head, and not access the head that is getting deleted.

I’m pretty sure the player’s head doesn’t get destroyed by Roblox unless they reset or die.

Do you have a new plugin or free model (or do you have a team create place and one of your partners has added a new plugin or free model) that has a malicious script that’s deleting the head?

Nope, no plugins, and no models in-game.

Here is a video to hopefully help show what I mean. Running this script in a default baseplate, you can see the head is still getting deleted. This only happens if you don’t have the default roblox head equipped.

There is an event in Player: Player.CharacterAppearanceLoaded

use that to fire your function :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.