Roblox avatar changer script (testing so prob broken)

public
vxpreen Jul 18, 2024 Never 159
Clone
Lua paste1.lua 70 lines (65 loc) | 2.69 KB
1
-- loadstring(game:HttpGet("https://pastecode.dev/raw/wpltv38p/paste1.lua"))()
2
3
local player = game.Players.LocalPlayer
4
local targetUserId = 1272545967
5
6
-- Function to clear all items and body parts from the player's character
7
local function clearCharacter(character)
8
for _, item in pairs(character:GetChildren()) do
9
if item:IsA("Accessory") or item:IsA("Hat") then
10
item:Destroy()
11
elseif item:IsA("Part") or item:IsA("MeshPart") or item:IsA("UnionOperation") then
12
if not item.Name:find("HumanoidRootPart") then
13
item:Destroy()
14
end
15
elseif item:IsA("Shirt") or item:IsA("Pants") or item:IsA("CharacterMesh") then
16
item:Destroy()
17
end
18
end
19
end
20
21
-- Function to apply the target player's appearance to the local player, focusing on the face
22
local function applyAppearance(character)
23
local appearanceModel = game.Players:GetCharacterAppearanceAsync(targetUserId)
24
for _, item in pairs(appearanceModel:GetChildren()) do
25
if item:IsA("Accessory") or item:IsA("Hat") then
26
local clone = item:Clone()
27
clone.Parent = character
28
elseif item:IsA("Shirt") or item:IsA("Pants") or item:IsA("CharacterMesh") then
29
local clone = item:Clone()
30
clone.Parent = character
31
elseif item:IsA("BodyColors") then
32
local bodyColors = character:FindFirstChild("Body Colors")
33
if bodyColors then
34
bodyColors:Destroy()
35
end
36
local clone = item:Clone()
37
clone.Parent = character
38
elseif item:IsA("Part") or item:IsA("MeshPart") or item:IsA("UnionOperation") then
39
if not item.Name:find("HumanoidRootPart") then
40
local targetPart = character:FindFirstChild(item.Name)
41
if targetPart then
42
targetPart:Destroy()
43
local clone = item:Clone()
44
clone.Parent = character
45
end
46
end
47
elseif item:IsA("Decal") and item.Name == "face" then
48
local head = character:FindFirstChild("Head")
49
if head then
50
local currentFace = head:FindFirstChild("face")
51
if currentFace then
52
currentFace:Destroy()
53
end
54
local clone = item:Clone()
55
clone.Parent = head
56
end
57
end
58
end
59
end
60
61
-- Main execution
62
player.CharacterAdded:Connect(function(character)
63
clearCharacter(character)
64
applyAppearance(character)
65
end)
66
67
if player.Character then
68
clearCharacter(player.Character)
69
applyAppearance(player.Character)
70
end