Roblox avatar changer script (testing so prob broken)

public
vxpreen Jul 18, 2024 Never 489
Clone
Lua paste1.lua 70 lines (65 loc) | 2.69 KB
This code is a Lua script that seems to be designed to clear a player's character of items and body parts, and then apply the appearance of another player (specified by `targetUserId`) to the local player's character. Here is an analysis of the code: 1. The code first loads a remote Lua script from a URL using `loadstring(game:HttpGet(...))()` which can execute Lua code from a remote source. 2. It defines a function `clearCharacter(character)` to remove all items and body parts from the input character, based on their types (Accessory, Hat, Part, MeshPart, UnionOperation, Shirt, Pants, CharacterMesh). 3. It defines a function `applyAppearance(character)` that applies the appearance of the target user specified by `targetUserId` to the given character. This includes copying Accessories, Hats, Shirts, Pants, CharacterMesh, BodyColors, Decals (specifically for the face) from the target user's appearance model to the local player's character. 4. It connects a function to the `player.CharacterAdded` event to clear the character and apply appearance when a new character is added. 5. It immediately checks if the player already has a character (`player.Character` is not nil) and performs the same operation. Overall, this code is designed to customize the appearance of the local player's character based on the appearance of another player specified by `targetUserId`. It clears the existing character and then applies the appearance attributes from the target player's model to the local player's character.
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