Problem setting a Player's face decal texture Id

I have a face-Decal system that basically sets your face’s decal depending on your health to make the game a bit more realistic
However, I have noticed that recently, My System has stopped working for Players, It still works for NPCs.
I haven’t been able to find the exact time or date it stopped working however what I do know is that my code is encountering any problems or errors, can anyone help identify this issue?
My Code:

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

local PlayerfaceSetter = script:FindFirstChild("Playerface-Setter")
local Head = script.Parent:WaitForChild("Head",15)

if not Head then
	return
end

local Decal = Head:WaitForChild("face",15) or Head:WaitForChild("Face",15)
local Humanoid = script.Parent:FindFirstChildOfClass("Humanoid")

if not Decal or not Humanoid then
	return
end

local DefaultFace = string.match(Decal.Texture,"%d+")
local Face1 = "8560915"
local Face2 = "141728515"
local DeadFace = "145854465"
local rbxlink = "rbxassetid://"

if DefaultFace then
	if DefaultFace == DeadFace then
		DefaultFace = "144080495"
	end
else
	DefaultFace = "144080495"	
end

Humanoid.Died:Connect(function()
	pcall(function()
		Decal.Texture = rbxlink .. DeadFace
	end)
end)

function Main()
	local Health = Humanoid.Health
	local Max = Humanoid.MaxHealth
	local DefaultPercent = Max * (75/100)
	local NormalPercent = Max * (50/100)
	local TiredPercent = Max * (25/100)
	if Health <= TiredPercent and Health < NormalPercent and Health < DefaultPercent then
		pcall(function()
			Decal.Texture = rbxlink .. Face2
		end)
	end
	if Health >= NormalPercent and Health > TiredPercent and Health < DefaultPercent then
		pcall(function()
			Decal.Texture = rbxlink .. Face1
		end)
	end
	if Health <= NormalPercent and Health > TiredPercent and Health < DefaultPercent then
		pcall(function()
			Decal.Texture = rbxlink .. Face1
		end)
	end
	if Health >= DefaultPercent and Health > TiredPercent and Health > NormalPercent then
		pcall(function()
			Decal.Texture = rbxlink .. DefaultFace
		end)
	end
end

while wait() do
	if Humanoid == nil or Humanoid.Parent == nil or Humanoid.Health <= 0 then
		break
	end
	Main()
end

Any help is greatly appreciated.
Note:
The Pcalls are not giving errors and, as said previously, code works fine with NPCs.

Seems to be working for me, but I removed the 4th line though- “Player-face-Setter”, not sure what this odes, but the script works awesome even without it!

@PhAnToMjose4605
are you sure it’s working, It’s not for me, The Player’s face doesn’t set, also the “Player-face-Setter” was another script I used as an attempt to fix the issue, please confirm so I can try re-installing Roblox, Thanks

Here’s the video of it working, I modified the script a small bit though- (just added print statements and deleted the extra script)

Btw I used your script in startplayerscripts => Startercharacterscripts

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

--local PlayerfaceSetter = script:FindFirstChild("Playerface-Setter")
local Head = script.Parent:WaitForChild("Head",15)

if not Head then
	return
end

local Decal = Head:WaitForChild("face",15) or Head:WaitForChild("Face",15)
local Humanoid = script.Parent:FindFirstChildOfClass("Humanoid")

if not Decal or not Humanoid then
	return
end

local DefaultFace = string.match(Decal.Texture,"%d+")
print(DefaultFace)
local Face1 = "8560915"
local Face2 = "141728515"
local DeadFace = "145854465"
local rbxlink = "rbxassetid://"

if DefaultFace then
	if DefaultFace == DeadFace then
		DefaultFace = "144080495"
	end
else
	DefaultFace = "144080495"	
end

Humanoid.Died:Connect(function()
	pcall(function()
		Decal.Texture = rbxlink .. DeadFace
		print("died, face changed")
	end)
end)

function Main()
	local Health = Humanoid.Health
	local Max = Humanoid.MaxHealth
	local DefaultPercent = Max * (75/100)
	local NormalPercent = Max * (50/100)
	local TiredPercent = Max * (25/100)
	if Health <= TiredPercent and Health < NormalPercent and Health < DefaultPercent then
		pcall(function()
			print("face2")
			Decal.Texture = rbxlink .. Face2
		end)
	end
	if Health >= NormalPercent and Health > TiredPercent and Health < DefaultPercent then
		pcall(function()
			print("face1")
			Decal.Texture = rbxlink .. Face1
		end)
	end
	if Health <= NormalPercent and Health > TiredPercent and Health < DefaultPercent then
		pcall(function()
			print("face1")
			Decal.Texture = rbxlink .. Face1
		end)
	end
	if Health >= DefaultPercent and Health > TiredPercent and Health > NormalPercent then
		pcall(function()
			print("default face")
			Decal.Texture = rbxlink .. DefaultFace
		end)
	end
end

while wait() do
	if Humanoid == nil or Humanoid.Parent == nil or Humanoid.Health <= 0 then
		break
	end
	Main()
end

Thank you for Confirming, it seems the problem is at how I place the script or in my installation of Roblox.

No probs! Goodluck on your game!

1 Like

Thanks, also, feel free to use the system if you want to