Tes avatar 2

public
vxpreen Jul 18, 2024 Never 90
Clone
Lua paste1.txt 78 lines (65 loc) | 2.6 KB
1
-- loadstring(game:HttpGet("https://pastecode.dev/raw/bscuhb3s/paste1.txt"))()
2
3
local Player = game.Players.LocalPlayer
4
local targetUserId = 2931004766
5
local waitTime = 0.5
6
7
-- Function to add an accessory to the character
8
local function addAccessoryToCharacter(accessory)
9
if not accessory:IsA("Accessory") then
10
warn("The provided object is not an accessory.")
11
return
12
end
13
14
-- Temporarily parent the accessory to Workspace to ensure it's fully loaded
15
accessory.Parent = workspace
16
17
-- Wait to ensure accessory is properly loaded
18
wait(waitTime)
19
20
-- Add the accessory to the character's humanoid
21
local character = Player.Character
22
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
23
24
if humanoid then
25
humanoid:AddAccessory(accessory)
26
else
27
warn("Humanoid not found in character.")
28
end
29
end
30
31
-- Function to apply target's head accessories to the local player's character
32
local function applyTargetHeadAccessories(character)
33
-- Retrieve the target's appearance
34
local success, appearanceModel = pcall(function()
35
return game.Players:GetCharacterAppearanceAsync(targetUserId)
36
end)
37
38
if not success then
39
warn("Failed to retrieve target's appearance.")
40
return
41
end
42
43
-- Check if the Head part exists
44
local head = character:FindFirstChild("Head")
45
if not head then
46
warn("Head part not found in character.")
47
return
48
end
49
50
-- Clear existing head accessories from the character
51
for _, accessory in pairs(character:GetChildren()) do
52
if accessory:IsA("Accessory") and accessory.Parent == head then
53
accessory:Destroy()
54
end
55
end
56
57
-- Apply each head accessory from the target's appearance
58
for _, item in pairs(appearanceModel:GetChildren()) do
59
if item:IsA("Accessory") and item:FindFirstChild("Handle") then
60
local accessoryClone = item:Clone()
61
accessoryClone.Parent = workspace -- Temporarily parent to Workspace
62
wait(waitTime) -- Wait to ensure accessory is loaded
63
addAccessoryToCharacter(accessoryClone) -- Add the accessory to the character
64
end
65
end
66
end
67
68
-- Main execution
69
local function onCharacterAdded(character)
70
wait(waitTime) -- Wait for the character to fully load
71
applyTargetHeadAccessories(character)
72
end
73
74
-- Connect to the CharacterAdded event and handle current character
75
Player.CharacterAdded:Connect(onCharacterAdded)
76
if Player.Character then
77
onCharacterAdded(Player.Character)
78
end