Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scaleCharacter(model)
- local scale = 1
- local noArm = CFrame.new(0,-(.25/scale),-(scale/1.75))
- local Arm = CFrame.new(0, (.05/scale),-(scale/12)) * CFrame.Angles(math.rad(15),0,0)
- local headScale = (6/3) * scale
- if not model then return end
- local joints = {}
- local parts = {}
- local h = model:findFirstChild("Humanoid")
- if h then
- h.Parent = nil
- end
- local function handleHat(hat)
- delay(1,function ()
- if hat:findFirstChild("Scaled") then return end
- Instance.new("StringValue",hat).Name = "Scaled"
- Spawn(function ()
- local h = hat:WaitForChild("Handle")
- local m = h:WaitForChild("Mesh")
- --h.Size = Vector3.new(0.2,0.2,0.2)
- m.Scale = m.Scale * headScale
- end)
- local yInc = (headScale-1)*.5
- hat.AttachmentPos = (hat.AttachmentPos * headScale) - (hat.AttachmentUp * Vector3.new(yInc,yInc,yInc))
- end)
- 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
- if v.Name == 'Head' then
- v.Size = v.Size * headScale
- elseif v.Name == 'Torso' then
- v.Size = (v.Size + Vector3.new(.25,-.15,0)) * scale
- elseif v.Name:match('Leg') then
- v.Size = (v.Size - Vector3.new(.15,.4,.15)) * scale
- else
- v.Size = (v.Size - Vector3.new(.25,.25,.25)) * scale
- end
- v.Anchored = false
- end
- for _,j in pairs(joints) do
- local scale = scale
- if j.Name == "Neck" then
- scale = (scale + headScale)/2 - (scale/12)
- end
- 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
- if j.Name:match('Shoulder') then
- j.C0 = (CFrame.new(unpack(c0)) * CFrame.Angles(-math.pi/4,0,0)) * noArm
- elseif j.Name:match('Hip') then
- j.C0 = CFrame.new(unpack(c0)) * CFrame.new(0,(.3/scale),(.075/scale))
- else
- j.C0 = CFrame.new(unpack(c0))
- end
- 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)
- elseif c:IsA("CharacterMesh") then
- local bodyPart = tostring(c.BodyPart)
- if (bodyPart):match('Arm') then
- local shoulder = model.Torso[bodyPart:match('Enum.BodyPart.(%u%l+)')..' Shoulder']
- shoulder.C0 = (shoulder.C0 * noArm:inverse()) * Arm
- end
- end
- end)
- if h then
- h.Parent = model
- end
- end
- function onPlayerJoin(player)
- local lastCFrame = nil
- local m = Instance.new("Model",workspace)
- m.Name = player.Name
- player.Character = m
- player.CharacterAdded:connect(function(char)
- local h = char:FindFirstChild("Humanoid")
- if h then
- h.Died:connect(function()
- lastCFrame = char.Torso.CFrame
- player:LoadCharacter(true)
- end)
- end
- scaleCharacter(char)
- wait()
- if lastCFrame then
- local torso = char:FindFirstChild('Torso')
- torso.CFrame = lastCFrame
- if char:FindFirstChild('ForceField') then
- char:FindFirstChild('ForceField'):Destroy()
- end
- end
- delay(1,function()
- local head = char:WaitForChild("Head")
- if head:FindFirstChild("Mesh") then
- if not (head.Mesh:IsA("SpecialMesh") and head.Mesh.MeshType == Enum.MeshType.Head
- and head.Mesh.Scale == Vector3.new(1.25, 1.25, 1.25)) then
- -- head is in weird position
- char.Torso.Neck.C0 = char.Torso.Neck.C0 * CFrame.new(0,0,-0.245)
- if head.Mesh:IsA("SpecialMesh") and head.Mesh.MeshType == Enum.MeshType.FileMesh then
- head.Mesh.Scale = head.Mesh.Scale * (6/3)
- end
- end
- end
- -- change the face to a cuter one
- head:WaitForChild("face").Texture = 'http://www.roblox.com/asset/?id=192522516'
- end)
- end)
- wait(1)
- player:LoadCharacter(true)
- end
- game.Players.PlayerAdded:connect(onPlayerJoin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement