im trying to make a skibidi toilet game (i know its a dead trend but i felt like it) where when you spawn it the toilet can have your avatars accessories and head coloring
my main issue would be that im trying to get the players avatar from their userid and its not working, i cant do player.character because i made the toilet their starter character
ive looked though out the dev forum and YouTube but no posts or videos helped with my problem
local sc = script.Parent
local neck = sc:FindFirstChild("neck")
local head = sc:FindFirstChild("Head")
local face = head:FindFirstChild("Face")
game.Players.PlayerAdded:Connect(function(plr)
local userid = plr.UserId
local avatarmodel = game.Players:GetCharacterAppearanceAsync(userid)
head.Color = avatarmodel:FindFirstChild("Head").Color
neck.Color = avatarmodel:FindFirstChild("Head").Color
face.Texture = avatarmodel:FindFirstChild("Head"):FindFirstChild("Face").Texture
if avatarmodel:FindFirstChildWhichIsA("Hat") then
local hat = avatarmodel:FindFirstChildWhichIsA("Hat")
hat.Parent = sc
end
end)
help
9 Likes
You are using a deprecated method.
Try utilizing the :GetCharacterAppearanceInfoAsync
method.
You can view what is returned to you via printing the table it provides back to you.
Here is the documentation for it:
:GetCharacterAppearanceInfoAsync
Also here is a slight demo that uses the body colors:
game.Players.PlayerAdded:Connect(function(plr)
local userid = plr.UserId
local avatarInfo = game.Players:GetCharacterAppearanceInfoAsync(userid)
head.Color = BrickColor.new(avatarInfo.bodyColors["headColorId"])
neck.Color = BrickColor.new(avatarInfo.bodyColors["torsoColorId"])
end)
3 Likes
this works for coloring the head and neck but how would i get the accessories and the face texture
1 Like
nvm i read the document you attached and it showed how to do this but i still cant get the colors to work for some reason
my script
local sc = script.Parent
local neck = sc:FindFirstChild("neck")
local head = sc:FindFirstChild("Head")
local bchead = sc:FindFirstChild("BodyColors").HeadColor
local face = head:FindFirstChild("Face")
game.Players.PlayerAdded:Connect(function(plr)
local userid = plr.UserId
local avatarinfo = game.Players:GetCharacterAppearanceInfoAsync(userid)
print(avatarinfo.BodyColors["HeadColor"])
bchead.Color = BrickColor.new(avatarinfo.BodyColors["headColorId"])
head.BrickColor = BrickColor.new(avatarinfo.BodyColors["headColorId"])
neck.BrickColor = BrickColor.new(avatarinfo.BodyColors["headColorId"])
--face.Texture = avatarinfo:FindFirstChild("Head"):FindFirstChild("Face").Texture
--if avatarinfo:FindFirstChildWhichIsA("Hat") then
--local hat = avatarinfo:FindFirstChildWhichIsA("Hat")
--hat.Parent = sc
--end
end)
1 Like
Is this a LocalScript or server Script?
Edit:
You are attempting to set a color to an id number of a BrickColor, try adding .Color
at the end of BrickColor.new(avatarinfo.BodyColors["headColorId"])
.
1 Like
its a serverscript, the originial problem was that the script was located in the character. i moved it to serverscriptservice and now it does stuff but i get this error
2 Likes
Open the table that it is providing you when printed out. Iâm not quite sure how it could be returning ânilâ unless the value is not being provided(which shouldnât happen). Try what I said in my previous response in regards to adding .Color
and see if that fixes it.
2 Likes
âź {
[âassetsâ] = {âŚ},
[âbodyColorsâ] = âź {
[âheadColorIdâ] = 24,
[âleftArmColorIdâ] = 24,
[âleftLegColorIdâ] = 24,
[ârightArmColorIdâ] = 24,
[ârightLegColorIdâ] = 24,
[âtorsoColorIdâ] = 194
},
[âdefaultPantsAppliedâ] = false,
[âdefaultShirtAppliedâ] = false,
[âemotesâ] = {âŚ},
[âplayerAvatarTypeâ] = âR6â,
[âscalesâ] = {âŚ}
} - Server - Script:10
2 Likes
BodyColors
should be bodyColors
.
2 Likes
im having trouble grabbing a specific accessory because they are numbered, would there be a way to check if its face accessory without knowing the number
how the table is formatted
1 Like
You could create a âfor loopâ for the âassetsâ key which checks the assetType.name
and checks if it is equal to âFaceâ and/or whatever other assets you need.
1 Like
i made this script which works perfectly for what im trying to do
and i can change it from face to hat if i wanted to do get an accessory
for i,asset in pairs(avatarinfo["assets"]) do
if asset["assetType"] then
local assetType = asset["assetType"]
if assetType["name"] == "Face" then
local faceId = asset["id"]
local faceAsset = insertservice:LoadAsset(faceId)
faceId = faceAsset.face.Texture
faceAsset:Destroy()
face.Texture = faceId
end
end
end
In a playerâs character, the standard face texture is named âfaceâ not âFaceâ
1 Like
its a custom startercharacter so i named it with an uppercase F
1 Like
I am mentioning the commented script
1 Like
can you quote what you are talking about?
1 Like
this
(pleaseremove30characterrule)
1 Like
i changed it from that a while ago
and facts
1 Like
im having a problem where im loading in the accessories and getting them on the avatar but some of them are fitted wrong, is there a way to fix this or do i have to deal with it
Since its a custom StarterCharacter, I believe you are gonna have to handle the logic with that or just leave it be.