Face changer doesn't work

  1. What do you want to achieve? Detect if player has a custom face id in them and if they do change it to something else

  2. What is the issue? The script changes for everybody faces even if they don’t have the custom face id

  3. What solutions have you tried so far? tried separating the ids and it didn’t work

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			for _, child in ipairs(character:GetChildren()) do
				if child.Name == "Head" then
					local decal = child:FindFirstChildWhichIsA("Decal") 
					if decal.Texture  == "http://www.roblox.com/asset/?id=customfaceid" or "http://www.roblox.com/asset/?id=customfaceid" or "http://www.roblox.com/asset/?id=customfaceid" or "http://www.roblox.com/asset/id?=customfaceid" then
						decal.Texture =  "rbxthumb://type=Asset&id=" .. DEADFACEID.. "&w=420&h=420"			 
					end
				end
				end
			end)
	end)
end)

Script is server, in servescriptservice, side note what i’m trying to do here is make a dead face changer but ONLY change if player has a custom face id.

1 Like

Move that to a local script, and try firing an event when the player dies.

Wouldn’t that like only appear to the user’s (the player who died) client?

2 Likes

When checking if then, any value that is not nil or false is considered true, in that line you are asking if decal.Texture is equal to a string, but, as the others are strings, it is considered true, it would read

if true/false or true or true or true or true then

which, eventually, is true.


Change the code to this

local Decal_Ids = {
	654,
}

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			for _, child in ipairs(character:GetChildren()) do
				if child.Name == "Head" then
					local decal = child:FindFirstChildWhichIsA("Decal")
					if decal and table.find(Decal_Ids, tonumber(decal.Texture:match("%d+"))) then
						decal.Texture =  "rbxthumb://type=Asset&id=" .. DEADFACEID.. "&w=420&h=420"			 
					end
				end
			end
		end)
	end)
end)

in Decal_Ids, put the id as a number and separated by a comma.


Sources: table.find, string:match("%d+"), if then

1 Like

do i use elseif if Decal_ids is a certain id?

1 Like

what? the line

if decal and table.find(Decal_Ids, tonumber(decal.Texture:match("%d+")) then

it means that, if it finds the id in Decal_ids, it will change the texture of the decal.

Got it, thanks also do i like make a similar script but with different decal ids (not the dead ones)? will that work?

Yes, same code but with a different table.

PS: mark my previous as solution post if it solved your problem.