So i have an character Scaling Script that used Hats so i updated it to use Accessory but changing the AttachmentPos in properties and in script didnt seem to do anything? Any help?
function scaleCharacter(model,scale)
if not model or not scale then return end
if not _G.ScaleCons then
_G.ScaleCons = {}
end
if _G.ScaleCons[model] then
_G.ScaleCons[model]:disconnect()
end
local joints = {}
local parts = {}
local h = model:findFirstChild("Humanoid")
if h then
h.Parent = nil
end
local function handleHat(hat)
if hat:findFirstChild("GotScaled") then return end
Instance.new("Flag",hat).Name = "GotScaled"
spawn(function ()
local h = hat:WaitForChild("Handle")
local m = h:WaitForChild("Mesh")
m.Scale = m.Scale * scale
end)
local yInc = (scale-1)*.5
hat.AttachmentPos = (hat.AttachmentPos * scale) - (hat.AttachmentUp * Vector3.new(yInc,yInc,yInc))
end
for _,v in pairs(model:GetChildren()) do
if v:IsA("BasePart") then
table.insert(parts,v)
v.Anchored = true;
v.FormFactor = "Custom";
for _,j in pairs(v:GetChildren()) do
if j:IsA("Motor6D") then
local t = {
Name = j.Name;
Parent = v;
Part0 = j.Part0;
Part1 = j.Part1;
C0 = j.C0;
C1 = j.C1;
}
table.insert(joints,t)
j:Destroy()
end
end
elseif v:IsA("Accessory") then
handleHat(v)
end
end
for _,v in pairs(parts) do
v.Size = v.Size * scale
v.Anchored = false
end
for _,j in pairs(joints) do
local c0 = {j.C0:components()}
local c1 = {j.C1:components()}
for i = 1,3 do
c0[i] = c0[i] * scale
c1[i] = c1[i] * scale
end
j.C0 = CFrame.new(unpack(c0))
j.C1 = CFrame.new(unpack(c1))
local n = Instance.new("Motor6D")
for k,v in pairs(j) do
n[k] = v
end
end
model.ChildAdded:connect(function (c)
if c:IsA("Accessory") then
handleHat(c)
end
end)
if h then
h.Parent = model
end
_G.ScaleCons[model] = con
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Wait()
scaleCharacter(plr.Character,0.5)
end)
