Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x = 30
- local z = 30
- local espeed = 17
- local wall_size = Vector3.new(10, 2047, 1)
- local grid_size = Vector3.new(10, 2047/2, 10)
- local b_wall_counter = 0
- local offset = Vector3.new(0, 0, 20)
- local dist = wall_size.X/2
- local roof = Instance.new("Part", script)
- local balls = Instance.new("Folder", script)
- balls.Name = "balls"
- local maze = Instance.new("Folder", script)
- maze.Name = "maze"
- local mazemaze = script.maze
- local pfs = game:GetService("PathfindingService")
- local params = {
- AgentRadius = 8;
- AgentHeight = 4;
- AgentCanJump = true;
- WaypointSpacing = 2;
- }
- local p = game:GetService("Players")
- local rs = game:GetService("RunService")
- local stuff = {}
- roof.Anchored = true
- roof.Size = Vector3.new(1,1,1)
- roof.Position = offset + Vector3.new(0, wall_size.Y+2.5, 0)
- roof.Size = Vector3.new(x*grid_size.X+wall_size.X+1, 5, z*grid_size.Z+wall_size.X+1)
- roof.Position += Vector3.new(x*grid_size.X/2, 0, z*grid_size.Z/2)
- roof.Material = "Concrete"
- roof.Color = Color3.new(.3, .3, .3)
- roof.Locked = true
- stuff[1] = roof
- local enemies = {}
- local chats = {
- "haha",
- "l bozo",
- "get good",
- "skill issue",
- "gg ez no re",
- "imagine dying to a ball :skull:"
- }
- function getpathpoints(start, en)
- local path = pfs:CreatePath()
- path:ComputeAsync(start, en)
- return path:GetWaypoints()
- end
- function whentouch(p, e)
- if p.Parent:FindFirstChild("Humanoid") and (not p:IsDescendantOf(balls)) then
- local hum = p.Parent.Humanoid
- hum:TakeDamage(e:GetAttribute("atk"))
- hum.Died:Connect(function() game:GetService("Chat"):Chat(e, chats[math.random(#chats)]) end)
- end
- end
- function findclosest(pos)
- local poss = {}
- local closest = 6^90
- local target = nil
- local overlapparams = OverlapParams.new()
- overlapparams.FilterDescendantsInstances = script:GetChildren()
- overlapparams.FilterType = Enum.RaycastFilterType.Exclude
- local entities = workspace:GetPartBoundsInRadius(pos, 4000, overlapparams)
- for i = 1,#entities do
- local hum = entities[i].Parent:FindFirstChild("Humanoid")
- local head = entities[i].Parent:FindFirstChild("Head")
- if hum and head then
- if entities[i].Name == "Head" then
- --print(entities[i])
- if (head.Position - pos).Magnitude < closest then
- target = head
- closest = (head.Position - pos).Magnitude
- end
- end
- end
- end
- return target
- end
- local floor = roof:Clone()
- floor.Parent = script
- floor.Position -= Vector3.new(0, wall_size.Y + 4.99/2, 0)
- floor.Size += Vector3.new(0, -4.99, 0)
- floor.Locked = true
- stuff[2] = floor
- function enemy(xp, zp)
- local model = Instance.new("Model", balls)
- local ene = Instance.new("Part", model)
- ene.Shape = "Ball"
- ene.Position = Vector3.new(xp, 2, zp)
- ene.Velocity = Vector3.new(math.random(), math.random(), math.random())
- ene.Name = "HumanoidRootPart"
- local humanoid = Instance.new("Humanoid", model)
- humanoid.WalkSpeed = espeed
- ene:SetAttribute("atk", .5)
- if math.random() < (1/30) then
- ene.Color = Color3.new(1,0,0)
- humanoid.MaxHealth = 500
- humanoid.Health = 500
- ene:SetAttribute("atk",3)
- end
- return ene
- end
- local coros = {}
- owner.Chatted:Connect(function(msg)
- if string.sub(msg, 1, 3) == "*sp" then
- local amoun = tonumber(string.sub(msg, 4)) or 1
- for i = 1, amoun do
- local enemyd = enemy(math.random() * x * grid_size.X, math.random() * z * grid_size.Z)
- table.insert(enemies, enemyd)
- enemyd.Parent.Humanoid.Died:Connect(function()
- table.remove(enemies, table.find(enemies, enemyd))
- enemyd.Parent:Destroy()
- end)
- enemyd.Touched:Connect(function(touched) whentouch(touched, enemyd) end)
- local IOP = coroutine.wrap(function()
- while task.wait() do
- if enemyd ~= nil then
- local enem = enemyd
- pcall(function() enem:SetNetworkOwner(nil) end)
- local closest = findclosest(enem.Position)
- local rayparams = RaycastParams.new()
- rayparams.FilterDescendantsInstances = { script.balls }
- local points = getpathpoints(enem.Position, closest.Position)
- table.remove(points, 1)
- local coro = coroutine.create(function()
- for j = 1, #points do
- local pointpos = points[j].Position
- local vis = Instance.new("Part", enem)
- vis.Size = Vector3.one
- vis.Position = pointpos
- vis.Anchored = true
- vis.CanCollide = false
- if enem.Parent then
- local dist = (pointpos - enem.Position).Magnitude
- enem.Parent.Humanoid:MoveTo(pointpos)
- enem.Parent.Humanoid.MoveToFinished:Wait()
- end
- end
- end)
- local rtoclosest = workspace:Raycast(enem.Position, (closest.Position - enem.Position), rayparams)
- if rtoclosest and enem.Parent then
- if not rtoclosest.Instance:IsDescendantOf(closest.Parent) then
- local coroscoro = coros[i + #enemies]
- if coroscoro then
- if coroutine.status(coroscoro) == "dead" then
- coroutine.resume(coro)
- --print(coros[i + #enemies] == coro)
- end
- else
- coroutine.resume(coro)
- --print(coros[i + #enemies] == coro)
- end
- else
- coroutine.close(coros[i + #enemies] or coroutine.create(function() end))
- coroutine.wrap(function() enem.Parent.Humanoid:MoveTo(closest.Position) end)()
- end
- else
- if enem.Parent then
- coroutine.close(coros[i + #enemies] or coroutine.create(function() end))
- coroutine.wrap(function() enem.Parent.Humanoid:MoveTo(closest.Position) end)()
- end
- end
- coros[i + #enemies] = coro
- end
- end
- end)
- IOP()
- task.wait()
- end
- print("d")
- end
- if string.sub(msg, 1, 2) == "*h" then
- for i = 1, #enemies do
- local enemi = enemies[i]
- if enemi:FindFirstChild("Highlight") == nil then
- local hi = Instance.new("Highlight", enemi)
- task.wait()
- end
- end
- print("dh")
- end
- if string.sub(msg, 1, 2) == "*r" then
- for i = 1, #enemies do
- local enemi = enemies[i]
- if enemi:FindFirstChild("Highlight") then
- enemi.Highlight:Destroy()
- task.wait()
- end
- end
- print("dr")
- end
- if string.sub(msg, 1, 3) == "*ce" then
- for i = #enemies, 1, -1 do
- local enemi = enemies[i]
- enemi:Destroy()
- table.remove(enemies, i)
- task.wait()
- end
- print("dc")
- end
- if msg == "*nm" then
- mazemaze.Parent = game:GetService("ReplicatedStorage")
- end
- if msg == "*ym" then
- mazemaze.Parent = script
- end
- end)
- for xpos = 0, x do
- for zpos = 0, z do
- --local random = math.round(math.noise(xpos/5, zpos/5)*2)
- local random = math.random(1, 4)
- local wall = Instance.new("SpawnLocation", maze)
- wall.Enabled = false
- wall.Orientation = Vector3.new(0, random*90, 0)
- wall.Size = wall_size
- wall.Material = "Concrete"
- wall.Position = Vector3.new(xpos, 1, zpos)*grid_size+offset
- wall.Position += wall.CFrame.LookVector*dist
- wall.Anchored = true
- wall.Locked = true
- if math.random() < 1/300 then
- wall.Color = Color3.new()
- wall.Transparency = .4
- b_wall_counter += 1
- end
- stuff[#stuff+1] = wall
- if (xpos % 8 == 0) and (zpos % 8 == 0) then
- local lightbulb = Instance.new("Part", maze)
- lightbulb.Size = Vector3.new(2, 1, 2)
- lightbulb.Position = Vector3.new(xpos, 2, zpos)*grid_size+offset-Vector3.new(0, 1, 0)
- lightbulb.Anchored = true
- lightbulb.Color = Color3.new(1, .6, .3)
- lightbulb.Material = "Neon"
- lightbulb.Locked = true
- stuff[#stuff+1] = lightbulb
- local light = Instance.new("SpotLight", lightbulb)
- light.Range = 35
- light.Face = "Bottom"
- light.Angle = 45
- light.Brightness = 1
- light.Color = Color3.new(1, 1, .8)
- end
- end
- end
- for i = 1,#game:GetService("Players"):GetChildren() do
- if p:children()[i].Character:FindFirstChild("Head") then
- if not p:children()[i].Character.Head:FindFirstChild("NLS") then
- NLS([[
- game:GetService("Lighting").Ambient = Color3.new(.119, .119, .119)
- game:GetService("Lighting").OutdoorAmbient = Color3.new()
- ]], game:GetService("Players"):children()[i].Character.Head)
- end
- end
- end
- print(b_wall_counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement