Advertisement
SheeityArtist

zambees

May 10th, 2017
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. local foundObjectList = {}
  2. local foundObjectIndex = 1
  3. local function findObjectHelper(model, objectName, className, listOfFoundObjects)
  4. if not model then return end
  5. local findStart, findEnd = string.find(model.Name, objectName)
  6. if findStart == 1 and findEnd == #(model.Name) then -- must match entire name
  7. if not className or model.className == className or (pcall(model.IsA, model, className) and model:IsA(className)) then
  8. table.insert(listOfFoundObjects, model)
  9. end
  10. end
  11. if pcall(model.GetChildren, model) then
  12. local modelChildren = model:GetChildren()
  13. for i = 1, #modelChildren do
  14. -- make sure not to resize tools, things tend to get complicated if we do
  15. if not (pcall(modelChildren[i].IsA, modelChildren[i], 'Tool') and modelChildren[i]:IsA('Tool')) then
  16. findObjectHelper(modelChildren[i], objectName, className, listOfFoundObjects)
  17. end
  18. end
  19. end
  20. end
  21.  
  22. local function resizeModelInternal(model, resizeFactor)
  23. local modelCFrame = model:GetModelCFrame()
  24. local modelSize = model:GetModelSize()
  25. local baseParts = {}
  26. local basePartCFrames = {}
  27. local joints = {}
  28. local jointParents = {}
  29. local meshes = {}
  30.  
  31. findObjectHelper(model, ".*", "BasePart", baseParts)
  32. findObjectHelper(model, ".*", "JointInstance", joints)
  33.  
  34. -- meshes don't inherit from anything accessible?
  35. findObjectHelper(model, ".*", "FileMesh", meshes) -- base class for SpecialMesh and FileMesh
  36. findObjectHelper(model, ".*", "CylinderMesh", meshes)
  37. findObjectHelper(model, ".*", "BlockMesh", meshes)
  38.  
  39. -- store the CFrames, so our other changes don't rearrange stuff
  40. for _, basePart in pairs(baseParts) do
  41. basePartCFrames[basePart] = basePart.CFrame
  42. end
  43.  
  44. -- scale meshes
  45. for _,mesh in pairs(meshes) do
  46. -- This is a nasty hack because head meshes scale relative to the part's size
  47. -- thus scaling the mesh and the head gives u 2x the size
  48. if mesh.Parent.Name ~= "Head" then
  49. mesh.Scale = mesh.Scale * resizeFactor
  50. end
  51. end
  52.  
  53. -- scale joints
  54. for _, joint in pairs(joints) do
  55. joint.C0 = joint.C0 + (joint.C0.p) * (resizeFactor - 1)
  56. joint.C1 = joint.C1 + (joint.C1.p) * (resizeFactor - 1)
  57. jointParents[joint] = joint.Parent
  58. end
  59.  
  60. -- scale parts and reposition them within the model
  61. for _, basePart in pairs(baseParts) do
  62. if pcall(function() basePart.FormFactor = "Custom" end) then basePart.FormFactor = "Custom" end
  63. basePart.Size = basePart.Size * resizeFactor
  64. local oldCFrame = basePartCFrames[basePart]
  65. local oldPositionInModel = modelCFrame:pointToObjectSpace(oldCFrame.p)
  66. local distanceFromCorner = oldPositionInModel + modelSize/2
  67. distanceFromCorner = distanceFromCorner * resizeFactor
  68.  
  69. local newPositionInSpace = modelCFrame:pointToWorldSpace(distanceFromCorner - modelSize/2)
  70. basePart.CFrame = oldCFrame - oldCFrame.p + newPositionInSpace
  71. end
  72.  
  73. -- pop the joints back, because they prolly got borked
  74. for _, joint in pairs(joints) do
  75. joint.Parent = jointParents[joint]
  76. end
  77.  
  78. return model
  79. end
  80.  
  81. local function resizeImplementation(modelList, resizeFactor)
  82. if type(modelList) ~= "table" then modelList = {modelList} end
  83.  
  84. for _, model in pairs(modelList) do
  85. --if model.Name ~= "BackPack" then
  86. resizeModelInternal(model, resizeFactor)
  87. --end
  88. end
  89. return modelList
  90. end
  91.  
  92. hint = Instance.new("Hint",game.Workspace)
  93.  
  94. zamcount = 0
  95.  
  96. function ZambieCount()
  97. zamcount = 0
  98. local ch = game.Workspace:GetChildren()
  99. for i = 1, #ch do
  100. if ch[i]:FindFirstChild("Zambie")~=nil then
  101. zamcount = zamcount + 1
  102. end
  103. end
  104. end
  105. game.Workspace.ChildAdded:connect(ZambieCount)
  106. game.Workspace.ChildRemoved:connect(ZambieCount)
  107.  
  108. function createBoss()
  109. local z = game.InsertService:LoadAsset(93601062)
  110. z.Parent = game.Workspace
  111. z.Zombie.Head.Mesh.Scale = Vector3.new(1.5,1.5,1.5)
  112. z:MoveTo(Vector3.new(math.random(-200,200),0,math.random(-200,200)))
  113. resizeImplementation(z.Zombie,1.5)
  114. z.Zombie.Humanoid.MaxHealth = 300
  115. z.Zombie.Humanoid.Health = 300
  116. z.Zombie.Name = "Zambie"
  117. end
  118.  
  119. while wait(1) do
  120. if hint ~= nil then
  121. hint.Text = "Zambie Count: "..zamcount
  122. elseif hint == nil then
  123. hint = Instance.new("Hint",game.Workspace)
  124. hint.Text = "Zambie Count: "..zamcount
  125. end
  126. if zamcount < 31 then
  127. local r = math.random(0,100)
  128. if r < 11 then
  129. createBoss()
  130. else
  131. local z = game.InsertService:LoadAsset(93601062)
  132. z.Parent = game.Workspace
  133. z:MoveTo(Vector3.new(math.random(-200,200),0,math.random(-200,200)))
  134. z.Zombie.Name = "Zambie"
  135. end
  136. end
  137. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement