Converting Face to Default

I’m trying to change it so when a player joins their face turns into the default face,

my script in workspace:
local Players = game:GetService(“Players”)

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	local head = player.Character:FindFirstChild("Head")
	local face = head:FindFirstChild("face")
	if face then
		print("face = true")
        --this is just detecting if the face is there, when I make it so the face turns default I will add it on
	end
end)
1 Like

I don’t understand. Your script works perfectly fine. Please specify!

Screen Shot 2022-07-15 at 3.35.31 PM
this happens

Try using WaitForChild() instead in the first:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	local head = player.Character:WaitForChild("Head")
	local face = head:FindFirstChild("face")
	if face then
		print("face = true")
        --this is just detecting if the face is there, when I make it so the face turns default I will add it on
	end
end)


this happens

I found out the issue. You didn’t wait for the character to spawn.

Here’s your fix:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character:FindFirstChild("Head")
		local face = head:FindFirstChild("face")
		if face then
			print("face = true")
			--this is just detecting if the face is there, when I make it so the face turns default I will add it on
		end
	end)
end)
1 Like

thanks! but, im still on the problem of changing the face to default. let me see if I can try to implement that

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character:FindFirstChild("Head")
		local face = head:FindFirstChild("face")
		if face then
			print("face = true")
			face.Texture = "rbxasset://textures/face.png"
		end
	end)
end)

this is what the script is, I dont see any errors in the output but it doesn’t work

im going to try to use an actual decal

2 Likes

this is the code now:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character:FindFirstChild("Head")
		local face = head:FindFirstChild("face")
		if face then
			print("face = true")
			face.Texture = "http://www.roblox.com/asset/?id=7322198887"
		end
	end)
end)

but it still doesn’t work

Roblox site IDs are not the same as studio IDs. Put your decal ID into a decal, and copy the ID it changes to. If you are using the right ID, use "rbxassetid://7322198887"

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character:FindFirstChild("Head")
		local face = head:FindFirstChild("face")
		if face then
			print("face = true")
			face.Texture = "rbxassetid://7322198887"
		end
	end)
end)

I dont know what’s wrong with it, lol

ended up just making a change face script in the spawn part

For anyone else curious about this, here’s a script I managed to get working, as well as explanations as to how it works:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player) -- Detect when the player joins

	player.CharacterAppearanceLoaded:Connect(function(character) -- Detect when the player's character's appearance loads
-- (Notice the use of CharacterAppearanceLoaded, rather than CharacterAdded.
-- This is done to make sure that every part of the character has loaded.)

		local head = character:WaitForChild("Head") -- Wait for the character's head, just for extra safety
		local face = head:WaitForChild("face") -- Wait for the "face" decal, also for safety

		if face then -- If the face has been found (which, ideally, it should have been),

			print("Face found") -- Print a confirmation that the character's face has been found

			face.Texture = "rbxassetid://7322198887" -- Set the face decal to the specified asset
            -- (which, in this case, is the default face)

		end
	end)
end)

I changed this to the solution just to be generous :wink:

No need for the if then face bit, the previous line of code will yield the script indefinitely if a ‘face’ instance isn’t found.

You also don’t need to yield (since you’re waiting for ‘CharacterAppearanceLoaded’ to fire anyway).

local Game = game
local Players = Game:GetService("Players")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		if not Player:HasAppearanceLoaded() then Player.CharacterAppearanceLoaded:Wait() end
		Character.Head.face.Texture = "rbxassetid://0"
	end
	
	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)
1 Like