Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Use q and e to control--
- local function getSizeAndCFrame(part,center,scale)
- local size=part.Size*scale
- print(size,part.Size)
- local cframe=center:toWorldSpace(center:toObjectSpace(part.CFrame)+(center:toObjectSpace(part.CFrame).p*(scale-1)))
- return size,cframe
- end
- local function fixMeshes(part,scale)
- --clone:ClearAllChildren()
- local tMeshes={}
- for k,v in pairs(part:children()) do
- if v:IsA("DataModelMesh") then
- table.insert(tMeshes,v)
- end
- end
- if #tMeshes<0 then return end
- for k,mesh in pairs(tMeshes) do
- print(mesh:GetFullName())
- if mesh:IsA("SpecialMesh") and mesh.MeshType==Enum.MeshType.FileMesh then
- mesh.Scale = mesh.Scale * scale
- end
- end
- end
- local function scaleModel(model,scale)
- local center=model:GetModelCFrame()
- local tParts={}
- local tJoints={}
- local function addToTable(instance)
- if instance:IsA("JointInstance") then
- table.insert(tJoints,{instance,oldParent=instance.Parent})
- elseif instance:IsA("BasePart") then
- table.insert(tParts,instance)
- elseif instance:IsA("ShirtGraphic") then
- instance.Graphic=''
- instance:Destroy()
- elseif instance:IsA("CharacterMesh") or instance:IsA("Clothing") then
- instance:Destroy()
- end
- for k,v in pairs(instance:children()) do
- addToTable(v)
- end
- end
- local tSizes={}
- addToTable(model)
- for k,v in pairs(tParts) do
- --v.FormFactor="Custom"
- tSizes[v]={getSizeAndCFrame(v,center,scale)}
- fixMeshes(v,scale)
- end
- for k,v in pairs(tJoints) do
- tSizes[v]={v[1].C0+(v[1].C0.p*(scale-1)),v[1].C1+(v[1].C1.p*(scale-1))}
- end
- --This cant take too long
- for k,v in pairs(tJoints) do
- v[1].Parent=nil
- end
- for k,v in pairs(tParts) do
- v.Size,v.CFrame=unpack(tSizes[v])
- end
- for k,v in pairs(tJoints) do
- j=v[1]
- j.C0,j.C1=unpack(tSizes[v])
- end
- for k,v in pairs(tJoints) do
- v[1].Parent=v.oldParent
- end
- return model
- end
- local scale=1
- while true do
- key=game.Players.LocalPlayer:GetMouse().KeyDown:wait()
- if key:lower()=="e" --[[and scale>0.5]] then
- scale=scale-0.1
- scaleModel(game.Players.LocalPlayer.Character,scale/scale+0.1)
- elseif key:lower()=="q" --[[and scale<5]] then
- scale=scale+0.1
- scaleModel(game.Players.LocalPlayer.Character,scale/scale-0.1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment