Hello, i have a problem with copying the player’s accessories onto a smaller rig.
Here is the script:
local tool = script.Parent
local hammerModel = tool:WaitForChild("HammerModel")
local noob = hammerModel:WaitForChild("Noob")
local handle = tool:WaitForChild("Handle")
local Players = game:GetService("Players")
local function weld(p0, p1)
local w = Instance.new("WeldConstraint")
w.Part0 = p0
w.Part1 = p1
w.Parent = p0
end
local function applyPlayerAppearance(player)
local char = player.Character
if not char then return end
-- Body colors
local bodyColors = char:FindFirstChildOfClass("BodyColors")
if bodyColors then
bodyColors:Clone().Parent = noob
end
-- Shirt
local shirt = char:FindFirstChildOfClass("Shirt")
if shirt then
shirt:Clone().Parent = noob
end
-- Pants
local pants = char:FindFirstChildOfClass("Pants")
if pants then
pants:Clone().Parent = noob
end
-- Copy Face decal
local face = char:FindFirstChild("Head"):FindFirstChild("face")
if face and noob:FindFirstChild("Head") then
noob.Head.face:Destroy()
face:Clone().Parent = noob.Head
end
-- Replace body parts appearance
for _, noobPart in ipairs(noob:GetChildren()) do
if noobPart:IsA("BasePart") then
local playerPart = char:FindFirstChild(noobPart.Name)
if playerPart then
noobPart.Color = playerPart.Color
noobPart.Material = playerPart.Material
noobPart.Transparency = playerPart.Transparency
end
weld(noobPart, handle)
end
end
-- Accessories
for _, acc in ipairs(char:GetChildren()) do
if acc:IsA("Accessory") then
local clone = acc:Clone()
clone.Parent = noob
local accHandle = clone:FindFirstChild("Handle")
if accHandle then
local attach = accHandle:FindFirstChildWhichIsA("Attachment")
if attach then
local attached = false
for _, np in ipairs(noob:GetChildren()) do
if np:IsA("BasePart") then
local match = np:FindFirstChild(attach.Name)
if match then
accHandle.CFrame = match.WorldCFrame
weld(accHandle, np)
attached = true
break
end
end
end
if not attached then
weld(accHandle, handle)
end
else
weld(accHandle, handle)
end
end
end
end
end
tool.Equipped:Connect(function()
local player = Players:GetPlayerFromCharacter(tool.Parent)
if not player then return end
applyPlayerAppearance(player)
end)
When i use it, the accessories don’t scale properly. So basically what i am trying to make is a hammer that is the players avatar instead of a noob model. do i have to change some properties in the humanoid of the noob? do i have to delete it?
Also, when i equip the tool, the noob tries to stand. and my player gets tipped over. soooo, i don’t know why that happens. someone please help. thanks.
This is a server-script in the tool by the way.