✓ Accepted answer
Server Script
local Market = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Market:UserOwnsGamePassAsync(Player.UserId, 0) then
wait(0.1)
for i, v in pairs(Character:GetChildren()) do
if v:IsA("Accoutrement") then
v:Destroy()
end
end
local newaccessory = Instance.new("Accessory")
newaccessory.Name = "NewHair"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.CanCollide = false
handle.Anchored = false
handle.Size = Vector3.new(1, 1, 1)
handle.Parent = newaccessory
local weld = Instance.new("Weld")
weld.Parent = handle
weld.Part0 = handle
weld.Part1 = Character:WaitForChild("Head")
local mesh = Instance.new("SpecialMesh")
mesh.Scale = Vector3.new(1, 1, 1)
mesh.Parent = handle
if Market:PlayerOwnsAsset(Player, 63690008) then
mesh.MeshId = "http://www.roblox.com/asset/?id=0"
mesh.TextureId = "http://www.roblox.com/asset/?id=0"
weld.C0 = CFrame.new(0, 0, 0)
elseif Market:PlayerOwnsAsset(Player, 451220849) then
mesh.MeshId = "http://www.roblox.com/asset/?id=0"
mesh.TextureId = "http://www.roblox.com/asset/?id=0"
weld.C0 = CFrame.new(0, 0, 0)
end
end
end)
end)
Explanations of the functions are written in the script
The player.CharacterAdded Event is used to get the player's Character when they join the game
There is no property to determine gender, but players are also unable to remove the default hairs from their inventory, the one's given when they join roblox based on their gender choice
2 comments
This isn't working. My code is the same, I added the Texture/Mesh ID's for 'Cinnamon Hair" For girls, and "Beautiful Hair for Beautiful People" For boys, and doesn't work.
You can change the word "Accoutrment" to "Accessory" and see if that helps, also, make sure to change the C0 CFrame, this code will create the accessory, but its position may be inside the player's head