Advertisement
SmokeDelsin

become a bloxikin

May 26th, 2015
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. function scaleCharacter(model)
  2. local scale = 1
  3. local noArm = CFrame.new(0,-(.25/scale),-(scale/1.75))
  4. local Arm = CFrame.new(0, (.05/scale),-(scale/12)) * CFrame.Angles(math.rad(15),0,0)
  5. local headScale = (6/3) * scale
  6. if not model then return end
  7. local joints = {}
  8. local parts = {}
  9. local h = model:findFirstChild("Humanoid")
  10. if h then
  11. h.Parent = nil
  12. end
  13. local function handleHat(hat)
  14. delay(1,function ()
  15. if hat:findFirstChild("Scaled") then return end
  16. Instance.new("StringValue",hat).Name = "Scaled"
  17. Spawn(function ()
  18. local h = hat:WaitForChild("Handle")
  19. local m = h:WaitForChild("Mesh")
  20. --h.Size = Vector3.new(0.2,0.2,0.2)
  21. m.Scale = m.Scale * headScale
  22. end)
  23. local yInc = (headScale-1)*.5
  24. hat.AttachmentPos = (hat.AttachmentPos * headScale) - (hat.AttachmentUp * Vector3.new(yInc,yInc,yInc))
  25. end)
  26. end
  27. for _,v in pairs(model:GetChildren()) do
  28. if v:IsA("BasePart") then
  29. table.insert(parts,v)
  30. v.Anchored = true;
  31. v.FormFactor = "Custom";
  32. for _,j in pairs(v:GetChildren()) do
  33. if j:IsA("Motor6D") then
  34. local t = {
  35. Name = j.Name;
  36. Parent = v;
  37. Part0 = j.Part0;
  38. Part1 = j.Part1;
  39. C0 = j.C0;
  40. C1 = j.C1;
  41. }
  42. table.insert(joints,t)
  43. j:Destroy()
  44. end
  45. end
  46. elseif v:IsA("Hat") then
  47. handleHat(v)
  48. end
  49. end
  50. for _,v in pairs(parts) do
  51. if v.Name == 'Head' then
  52. v.Size = v.Size * headScale
  53. elseif v.Name == 'Torso' then
  54. v.Size = (v.Size + Vector3.new(.25,-.15,0)) * scale
  55. elseif v.Name:match('Leg') then
  56. v.Size = (v.Size - Vector3.new(.15,.4,.15)) * scale
  57. else
  58. v.Size = (v.Size - Vector3.new(.25,.25,.25)) * scale
  59. end
  60. v.Anchored = false
  61. end
  62. for _,j in pairs(joints) do
  63. local scale = scale
  64. if j.Name == "Neck" then
  65. scale = (scale + headScale)/2 - (scale/12)
  66. end
  67. local c0 = {j.C0:components()}
  68. local c1 = {j.C1:components()}
  69. for i = 1,3 do
  70. c0[i] = c0[i] * scale
  71. c1[i] = c1[i] * scale
  72. end
  73. if j.Name:match('Shoulder') then
  74. j.C0 = (CFrame.new(unpack(c0)) * CFrame.Angles(-math.pi/4,0,0)) * noArm
  75.  
  76. elseif j.Name:match('Hip') then
  77. j.C0 = CFrame.new(unpack(c0)) * CFrame.new(0,(.3/scale),(.075/scale))
  78. else
  79. j.C0 = CFrame.new(unpack(c0))
  80. end
  81. j.C1 = CFrame.new(unpack(c1))
  82. local n = Instance.new("Motor6D")
  83. for k,v in pairs(j) do
  84. n[k] = v
  85. end
  86. end
  87. model.ChildAdded:connect(function (c)
  88. if c:IsA("Hat") then
  89. handleHat(c)
  90. elseif c:IsA("CharacterMesh") then
  91. local bodyPart = tostring(c.BodyPart)
  92. if (bodyPart):match('Arm') then
  93. local shoulder = model.Torso[bodyPart:match('Enum.BodyPart.(%u%l+)')..' Shoulder']
  94. shoulder.C0 = (shoulder.C0 * noArm:inverse()) * Arm
  95. end
  96. end
  97. end)
  98. if h then
  99. h.Parent = model
  100. end
  101. end
  102.  
  103. function onPlayerJoin(player)
  104. local lastCFrame = nil
  105. local m = Instance.new("Model",workspace)
  106. m.Name = player.Name
  107. player.Character = m
  108. player.CharacterAdded:connect(function(char)
  109. local h = char:FindFirstChild("Humanoid")
  110. if h then
  111. h.Died:connect(function()
  112. lastCFrame = char.Torso.CFrame
  113. player:LoadCharacter(true)
  114. end)
  115. end
  116. scaleCharacter(char)
  117. wait()
  118. if lastCFrame then
  119. local torso = char:FindFirstChild('Torso')
  120. torso.CFrame = lastCFrame
  121. if char:FindFirstChild('ForceField') then
  122. char:FindFirstChild('ForceField'):Destroy()
  123. end
  124. end
  125. delay(1,function()
  126. local head = char:WaitForChild("Head")
  127. if head:FindFirstChild("Mesh") then
  128. if not (head.Mesh:IsA("SpecialMesh") and head.Mesh.MeshType == Enum.MeshType.Head
  129. and head.Mesh.Scale == Vector3.new(1.25, 1.25, 1.25)) then
  130. -- head is in weird position
  131. char.Torso.Neck.C0 = char.Torso.Neck.C0 * CFrame.new(0,0,-0.245)
  132. if head.Mesh:IsA("SpecialMesh") and head.Mesh.MeshType == Enum.MeshType.FileMesh then
  133. head.Mesh.Scale = head.Mesh.Scale * (6/3)
  134. end
  135. end
  136. end
  137. -- change the face to a cuter one
  138. head:WaitForChild("face").Texture = 'http://www.roblox.com/asset/?id=192522516'
  139. end)
  140. end)
  141. wait(1)
  142. player:LoadCharacter(true)
  143. end
  144.  
  145. game.Players.PlayerAdded:connect(onPlayerJoin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement