Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local foundObjectList = {}
- local foundObjectIndex = 1
- local function findObjectHelper(model, objectName, className, listOfFoundObjects)
- if not model then return end
- local findStart, findEnd = string.find(model.Name, objectName)
- if findStart == 1 and findEnd == #(model.Name) then -- must match entire name
- if not className or model.className == className or (pcall(model.IsA, model, className) and model:IsA(className)) then
- table.insert(listOfFoundObjects, model)
- end
- end
- if pcall(model.GetChildren, model) then
- local modelChildren = model:GetChildren()
- for i = 1, #modelChildren do
- -- make sure not to resize tools, things tend to get complicated if we do
- if not (pcall(modelChildren[i].IsA, modelChildren[i], 'Tool') and modelChildren[i]:IsA('Tool')) then
- findObjectHelper(modelChildren[i], objectName, className, listOfFoundObjects)
- end
- end
- end
- end
- local function resizeModelInternal(model, resizeFactor)
- local modelCFrame = model:GetModelCFrame()
- local modelSize = model:GetModelSize()
- local baseParts = {}
- local basePartCFrames = {}
- local joints = {}
- local jointParents = {}
- local meshes = {}
- findObjectHelper(model, ".*", "BasePart", baseParts)
- findObjectHelper(model, ".*", "JointInstance", joints)
- -- meshes don't inherit from anything accessible?
- findObjectHelper(model, ".*", "FileMesh", meshes) -- base class for SpecialMesh and FileMesh
- findObjectHelper(model, ".*", "CylinderMesh", meshes)
- findObjectHelper(model, ".*", "BlockMesh", meshes)
- -- store the CFrames, so our other changes don't rearrange stuff
- for _, basePart in pairs(baseParts) do
- basePartCFrames[basePart] = basePart.CFrame
- end
- -- scale meshes
- for _,mesh in pairs(meshes) do
- -- This is a nasty hack because head meshes scale relative to the part's size
- -- thus scaling the mesh and the head gives u 2x the size
- if mesh.Parent.Name ~= "Head" then
- mesh.Scale = mesh.Scale * resizeFactor
- end
- end
- -- scale joints
- for _, joint in pairs(joints) do
- joint.C0 = joint.C0 + (joint.C0.p) * (resizeFactor - 1)
- joint.C1 = joint.C1 + (joint.C1.p) * (resizeFactor - 1)
- jointParents[joint] = joint.Parent
- end
- -- scale parts and reposition them within the model
- for _, basePart in pairs(baseParts) do
- if pcall(function() basePart.FormFactor = "Custom" end) then basePart.FormFactor = "Custom" end
- basePart.Size = basePart.Size * resizeFactor
- local oldCFrame = basePartCFrames[basePart]
- local oldPositionInModel = modelCFrame:pointToObjectSpace(oldCFrame.p)
- local distanceFromCorner = oldPositionInModel + modelSize/2
- distanceFromCorner = distanceFromCorner * resizeFactor
- local newPositionInSpace = modelCFrame:pointToWorldSpace(distanceFromCorner - modelSize/2)
- basePart.CFrame = oldCFrame - oldCFrame.p + newPositionInSpace
- end
- -- pop the joints back, because they prolly got borked
- for _, joint in pairs(joints) do
- joint.Parent = jointParents[joint]
- end
- return model
- end
- local function resizeImplementation(modelList, resizeFactor)
- if type(modelList) ~= "table" then modelList = {modelList} end
- for _, model in pairs(modelList) do
- --if model.Name ~= "BackPack" then
- resizeModelInternal(model, resizeFactor)
- --end
- end
- return modelList
- end
- hint = Instance.new("Hint",game.Workspace)
- zamcount = 0
- function ZambieCount()
- zamcount = 0
- local ch = game.Workspace:GetChildren()
- for i = 1, #ch do
- if ch[i]:FindFirstChild("Zambie")~=nil then
- zamcount = zamcount + 1
- end
- end
- end
- game.Workspace.ChildAdded:connect(ZambieCount)
- game.Workspace.ChildRemoved:connect(ZambieCount)
- function createBoss()
- local z = game.InsertService:LoadAsset(93601062)
- z.Parent = game.Workspace
- z.Zombie.Head.Mesh.Scale = Vector3.new(1.5,1.5,1.5)
- z:MoveTo(Vector3.new(math.random(-200,200),0,math.random(-200,200)))
- resizeImplementation(z.Zombie,1.5)
- z.Zombie.Humanoid.MaxHealth = 300
- z.Zombie.Humanoid.Health = 300
- z.Zombie.Name = "Zambie"
- end
- while wait(1) do
- if hint ~= nil then
- hint.Text = "Zambie Count: "..zamcount
- elseif hint == nil then
- hint = Instance.new("Hint",game.Workspace)
- hint.Text = "Zambie Count: "..zamcount
- end
- if zamcount < 31 then
- local r = math.random(0,100)
- if r < 11 then
- createBoss()
- else
- local z = game.InsertService:LoadAsset(93601062)
- z.Parent = game.Workspace
- z:MoveTo(Vector3.new(math.random(-200,200),0,math.random(-200,200)))
- z.Zombie.Name = "Zambie"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement