Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. function scaleCharacter(Torso,scale)
  2. if not model or not scale then return end
  3. if not _G.ScaleCons then
  4. _G.ScaleCons = {}
  5. end
  6. if _G.ScaleCons[model] then
  7. _G.ScaleCons[model]:disconnect()
  8. end
  9. local joints = {}
  10. local parts = {}
  11. local h = model:findFirstChild("Humanoid")
  12. if h then
  13. h.Parent = nil
  14. end
  15. local function handleHat(hat)
  16. if hat:findFirstChild("GotScaled") then return end
  17. Instance.new("Flag",hat).Name = "GotScaled"
  18. Spawn(function ()
  19. local h = hat:WaitForChild("Handle")
  20. local m = h:WaitForChild("Mesh")
  21. m.Scale = m.Scale * scale
  22. end)
  23. local yInc = (scale-1)*.5
  24. hat.AttachmentPos = (hat.AttachmentPos * scale) - (hat.AttachmentUp * Vector3.new(yInc,yInc,yInc))
  25. end
  26. for _,v in pairs(model:GetChildren()) do
  27. if v:IsA("BasePart") then
  28. table.insert(parts,v)
  29. v.Anchored = true;
  30. v.FormFactor = "Custom";
  31. for _,j in pairs(v:GetChildren()) do
  32. if j:IsA("Motor6D") then
  33. local t = {
  34. Name = j.Name;
  35. Parent = v;
  36. Part0 = j.Part0;
  37. Part1 = j.Part1;
  38. C0 = j.C0;
  39. C1 = j.C1;
  40. }
  41. table.insert(joints,t)
  42. j:Destroy()
  43. end
  44. end
  45. elseif v:IsA("Hat") then
  46. handleHat(v)
  47. end
  48. end
  49. for _,v in pairs(parts) do
  50. v.Size = v.Size * scale
  51. v.Anchored = false
  52. end
  53. for _,j in pairs(joints) do
  54. local c0 = {j.C0:components()}
  55. local c1 = {j.C1:components()}
  56. for i = 1,3 do
  57. c0[i] = c0[i] * scale
  58. c1[i] = c1[i] * scale
  59. end
  60. j.C0 = CFrame.new(unpack(c0))
  61. j.C1 = CFrame.new(unpack(c1))
  62. local n = Instance.new("Motor6D")
  63. for k,v in pairs(j) do
  64. n[k] = v
  65. end
  66. end
  67. model.ChildAdded:connect(function (c)
  68. if c:IsA("Hat") then
  69. handleHat(c)
  70. end
  71. end)
  72. if h then
  73. h.Parent = model
  74. h.WalkSpeed = 16 * scale
  75. h.MaxHealth = 100 * scalea
  76. h.Health = (h.Health/h.MaxHealth)*(100*scale)
  77. end
  78. _G.ScaleCons[model] = con
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement