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.
@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
@FrozenModule No errors and the script says there’s no errors, but not printing?
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
@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.
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.
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)
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