Finding what face a player is wearing (CHILL)

Here’s Derpee’s daily question I guess I keep posting these every day lol

TL;DR at bottom

Alright so I made a Roblox group bot that can change other members’ roles in my group. I have a game that is activating the commands needed for this to happen. But here’s something I’m wondering. Before I get started, here’s the list of Roles in my group.

  • Follower (Normal Member)

  • Chill (Member wearing Chill Face)

  • Admin (Admin)

  • Admin+ (Admin for people I know personally)

  • Rank Bot (The bot account that ranks other members)

  • Derpee (Me)

So I was simply wondering if someone could explain how to find a member’s face locally. If this seems like a lot more than a couple of small lines, please let me know, and I will try to figure it out another way without breaking the rules and making someone write a really long script.

All I’m looking for is the one function (and the end function that calls it, if there is one) that will allow me to check for a player’s face worn.

TL;DR

I am simply asking for a hopefully one-line function to find out a player’s face through a LocalScript.

The face of a player is inside of a Decal object. From what I understand, you’re trying to look for a specific face.

Example code:

local player = game.Players.LocalPlayer
local character = player.Character

local face = character:FindFirstChild("Head"):FindFirstChild("face") -- gets the face decal from the player's character object

if face:IsA("Decal") then-- if it's a valid face, then...
    if face.Texture == "FaceIdYou'reLookingForHere" then
        -- do whatever
    end
end

The above code wasn’t tested, so please let me know if there are any issues. Also, be sure to use the asset ID of the official face that you’re looking for that’s by ROBLOX.

2 questions:

  • Is this supposed to go in a LocalScript (It looks like it to me because it’s finding the local player)?

  • Where would I put the LocalScript to have this work properly?

EDIT: I followed your DevForum Roblox Acc and main Roblox Acc

@DecodedMint There seems to be an error finding the face:
Players.Derpee_Kirbee.PlayerGui.LocalScript:4: attempt to index nil with 'FindFirstChild'

EDIT: I see that it’s trying to look in the PlayerGui I believe?

ANOTHER EDIT:
Here’s the current script with that error:

local player = game.Players.LocalPlayer

local character = player.Character

local face = character:FindFirstChild("Head"):FindFirstChild("face") -- gets the face decal from the player's character object

if face:IsA("Decal") then-- if it's a valid face, then...

if face.Texture == "7074764" then

print("Player is wearing Chill Face!")

end

end
local character = player.Character or player.CharacterAdded:Wait()

local face = character:WaitForChild("Head"):WaitForChild("face") -- ge

Try replacing that part with this.

@FrozenModule No errors and the script says there’s no errors, but not printing? :confused:

You just changed your username?

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local face = character:WaitForChild("Head"):WaitForChild("face") 

if face:IsA("Decal") then-- if it's a valid face, then...
	if face.Texture == "7074764" then
		print("Player is wearing Chill Face!")
	end
end

local character = game.Players.LocalPlayer.Character
wait(4) – waits for character
if character:WaitForChild(“Head”).Face.ImageId == “Chill face” then

end

Try doing print tests. After the if statements print something to see if the code is getting there.

If you are asking me I did not change my username.

@HarrowedCrobix Don’t use wait(x) to wait for character to load, use local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() instead because using wait(x) can cause:
a)Cause script to over yield for no good reason.
b)In some rare cases, the provided x parameter might be too short for the character to be actually added to the workspace.

Wow I thought you were @DecodedMint that’s how tired my brain is. You guys look so alike and are both supplying ideas lol

EDIT:

both of the if statements?

Yes try both if statements and see if its printing.

Did this and it’s printing both of them (test and test1):

local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local face = character:WaitForChild("Head"):WaitForChild("face")

if face:IsA("Decal") then-- if it's a valid face, then...

if face.Texture == "7074764" then

print("Player is wearing Chill Face!")

end

print("test")

end

print("test1")

Try running your game in studio, go to your character in workspace, open up the head, go to the face, and see what it says on the face decal. Maybe the texture is formatted differently.

That’s it it prints I needed to have the beginning (http://www.roblox.com/asset/?id=) in there too to have
http://www.roblox.com/asset/?id=7074749
and now it prints
Thanks for the help🙂

1 Like

There is an event for when a player is added

Also you can use string.find instead of posting the full roblox asset ID

Finally if you don’t mind marking your post as the solution so people know that this is solved!

local player = game.Players.LocalPlayer

player.CharacterAdded:Connect(function(character)
   local face = character:FindFirstChild("Head"):FindFirstChild("face") -- gets the face decal from the player's character object

   if face:IsA("Decal") then
       if string.find(face.Texture, 7074764) then
           -- do whatever
       end
   end
end)

You can do this in a server script.

sadly I forgot where does humanoiddescription place in, but I’m asumming it is in character, not in humanoid

game.Players.PlayerAdded:Connect(function(plr)
repeat wait() until plr.Character or plr.CharacterAdded
local hum = plr.Character.HumanoidDescription

if hum.FaceID = --[[ id (put the id of the face --]]  then

--thats where your bot goes from there.
end


end


1 Like