Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How To Change Hair when Spawn ?

Asked by 5 years ago

I want to creae a script To change the hair of the player when they spawn .. I tested to change the meshId And The TextureId but the problem is that the hair is not in the head so idk how to do that so if you know its wil be great . :) thx

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Try first finding the Character like this:

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait() --This tries to find the character, and if it doesnt, we have the "or" to try and wait for the character, the like "catch it" when it shows up.

After that, just change the hair by finding it. The problem is - not all hairs have the same name. What do we do then? Well, we can add a custom hair. Remove all the accessories (look it up, its easy and there are tutorials on how to do it.. I am not going to go into that) - add the hair and weld it to the head. You can position it right and there you go.

--You can add the hair from scratch via the script
local hair = Instance.new("MeshPart", char)
local hair.MeshId = (id)

local w = Instance.new("Weld", hair) --I am not sure how weld works, pretty sure its like this.
w.Part1 = hair
w.Part2 = Char.head
hair.CFrame = --(Ur CFrame, play with it.)

--or

--You can already make it and store it (In replicated storage for example)
local hair = game.ReplicatedStorage.hair:Clone()

local w = Instance.new("Weld", hair) --I am not sure how weld works, pretty sure its like this.
w.Part1 = hair
w.Part2 = Char.head
hair.CFrame = --(Ur CFrame, play with it.)
Ad

Answer this question