Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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("Hat") 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("Hat") then
- handleHat(c)
- end
- end)
- if h then
- h.Parent = model
- h.WalkSpeed = 16 * scale
- h.MaxHealth = 100 * scale
- h.Health = (h.Health/h.MaxHealth)*(100*scale)
- end
- _G.ScaleCons[model] = con
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement