-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMorph.lua
More file actions
63 lines (52 loc) · 1.81 KB
/
Morph.lua
File metadata and controls
63 lines (52 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local Players = game:GetService("Players")
local player = Players.LocalPlayer
function morphToUser(userId)
local character = player.Character
if not character then return end
local appearance = Players:GetCharacterAppearanceAsync(userId)
if not appearance then return end
local toRemove = {
["Accessory"] = true,
["Shirt"] = true,
["Pants"] = true,
["CharacterMesh"] = true,
["Hat"] = true,
["BodyColors"] = true
}
for _, item in ipairs(character:GetDescendants()) do
if toRemove[item.ClassName] then
item:Destroy()
end
end
local face = character.Head:FindFirstChild("face")
if face then face:Destroy() end
for _, item in ipairs(appearance:GetChildren()) do
if item:IsA("Shirt") or item:IsA("Pants") or item:IsA("BodyColors") then
item.Parent = character
elseif item:IsA("Accessory") then
character.Humanoid:AddAccessory(item)
elseif item.Name == character.Humanoid.RigType.Name then
local mesh = item:FindFirstChildOfClass("CharacterMesh")
if mesh then mesh.Parent = character end
end
end
local newFace = appearance:FindFirstChild("face")
if newFace then
newFace.Parent = character.Head
else
local defaultFace = Instance.new("Decal")
defaultFace.Name = "face"
defaultFace.Face = "Front"
defaultFace.Texture = "rbxasset://textures/face.png"
defaultFace.Parent = character.Head
end
character.Parent = nil
character.Parent = workspace
end
local function onCharacterAdded(character)
morphToUser(getgenv().userId)
end
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end