Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This script is from TDS game which I scripted few days ago
- local function spawnZombiesWithSpecialAbilities(roundNumber, mapName, RoundType, PlayerInRound)
- local roundInfo = RoundData[RoundType][roundNumber]
- if not roundInfo then
- warn("Round not found in data!")
- return
- end
- for zombieType, quantity in pairs(roundInfo) do
- print("Spawning " .. quantity .. " " .. zombieType .. "(s) with abilities for Round " .. roundNumber)
- if EndRound.ShouldEndSubrubanRounds == true then
- break
- end
- for i = 1, quantity do
- if EndRound.ShouldEndSubrubanRounds == true then
- for _, child in pairs(workspace:FindFirstChild(mapName).SpawnedZombies:GetChildren()) do
- child:Destroy()
- end
- break
- end
- local CloneZombie = ReplicatedStorage.Zombies:FindFirstChild(zombieType):Clone()
- CloneZombie.Parent = workspace:FindFirstChild(mapName).SpawnedZombies
- CloneZombie.HumanoidRootPart.CFrame = workspace:FindFirstChild(mapName).MovingPoints["1"].CFrame
- -- Apply random abilities to zombies for added challenge
- local randomAbility = math.random(1, 3)
- if randomAbility == 1 then
- CloneZombie.Humanoid.WalkSpeed = 50 -- Increased speed
- print(zombieType .. " gained speed boost!")
- elseif randomAbility == 2 then
- CloneZombie.Humanoid.Health = CloneZombie.Humanoid.Health * 2 -- Increased health
- print(zombieType .. " gained extra health!")
- elseif randomAbility == 3 then
- local damageBoost = Instance.new("NumberValue")
- damageBoost.Name = "DamageBoost"
- damageBoost.Value = 25 -- Increased damage output
- damageBoost.Parent = CloneZombie
- print(zombieType .. " gained damage boost!")
- end
- wait(1.5)
- end
- repeat
- wait()
- until #workspace:FindFirstChild(mapName).SpawnedZombies:GetChildren() == 0
- if RoundType == "EasyRound" then
- if roundNumber == EasyRoundLenght then
- for _, playerInRound in pairs(PlayerInRound) do
- playerInRound.PlayerGui.ShowRound.Enabled = false
- task.delay(3, function()
- playerInRound.Character.PrimaryPart.CFrame = workspace.Lobby.SpawnLocation.CFrame + Vector3.new(0, 2, 0)
- playerInRound.PlayerGui.RoundEndScreen.Frame.Visible = true
- playerInRound.PlayerGui.RoundEndScreen.Frame.TextLabel.Text = "You Won!"
- table.remove(PlayerInRound, table.find(PlayerInRound, playerInRound))
- end)
- end
- end
- end
- end
- end
- local function HandleRoundProgress(PlayerInRound, roundNumber, mapName, RoundType, RoundLenght)
- local remainingTime = RoundLenght
- local roundOver = false
- local roundStartTime = tick() -- Capture the time when the round starts
- -- Update the round timer on the player's UI
- for _, playerInRound in pairs(PlayerInRound) do
- playerInRound.PlayerGui.ShowRound.Frame.TextLabel.Text = "Round: " .. roundNumber
- end
- -- Function to update the timer every second
- local function updateTimer()
- while remainingTime > 0 and not roundOver do
- -- Calculate the elapsed time and update the remaining time
- remainingTime = RoundLenght - math.floor(tick() - roundStartTime)
- for _, playerInRound in pairs(PlayerInRound) do
- playerInRound.PlayerGui.ShowRound.Frame.TimerLabel.Text = "Time Left: " .. remainingTime .. "s"
- end
- wait(1)
- end
- end
- -- Function to check if round should end
- local function checkEndRound()
- -- If max damage reached or all zombies are defeated, end the round
- if SuburbanSiege.CurrentDamage.Value >= SuburbanSiege.MaxDamage.Value then
- for _, playerInRound in pairs(PlayerInRound) do
- playerInRound.PlayerGui.ShowRound.Enabled = false
- task.delay(3, function()
- playerInRound.Character.PrimaryPart.CFrame = workspace.Lobby.SpawnLocation.CFrame + Vector3.new(0, 2, 0)
- playerInRound.PlayerGui.RoundEndScreen.Frame.Visible = true
- playerInRound.PlayerGui.RoundEndScreen.Frame.TextLabel.Text = "You Defeated!"
- table.remove(PlayerInRound, table.find(PlayerInRound, playerInRound))
- end)
- end
- roundOver = true
- EndRound.ShouldEndSubrubanRounds = true
- elseif #workspace:FindFirstChild(mapName).SpawnedZombies:GetChildren() == 0 then
- for _, playerInRound in pairs(PlayerInRound) do
- playerInRound.PlayerGui.ShowRound.Enabled = false
- task.delay(3, function()
- playerInRound.Character.PrimaryPart.CFrame = workspace.Lobby.SpawnLocation.CFrame + Vector3.new(0, 2, 0)
- playerInRound.PlayerGui.RoundEndScreen.Frame.Visible = true
- playerInRound.PlayerGui.RoundEndScreen.Frame.TextLabel.Text = "You Won!"
- table.remove(PlayerInRound, table.find(PlayerInRound, playerInRound))
- end)
- end
- roundOver = true
- EndRound.ShouldEndSubrubanRounds = true
- end
- end
- -- Start updating the timer in a separate thread
- spawn(updateTimer)
- -- Spawn zombies for the round
- spawn(function()
- spawnZombiesForRound(roundNumber, mapName, RoundType, PlayerInRound)
- end)
- spawn(function()
- HandleRoundProgress(PlayerInRound, i, "suburban_siege", RoundType, RoundLenght)
- end)
- -- Continuously check for conditions that would end the round
- spawn(function()
- while not roundOver do
- checkEndRound()
- wait(1)
- end
- end)
- -- Wait for the round to end
- repeat
- wait(1)
- until roundOver
- -- Perform any final actions or cleanup after the round ends
- print("Round " .. roundNumber .. " has ended.")
- end
- -- Track player progress through rounds and assign rewards
- local function trackPlayerProgress(roundNumber, mapName, RoundType, PlayerInRound)
- local roundInfo = RoundData[RoundType][roundNumber]
- if not roundInfo then
- warn("Round not found in data!")
- return
- end
- for zombieType, quantity in pairs(roundInfo) do
- if EndRound.ShouldEndSubrubanRounds == true then
- break
- end
- for _, playerInRound in pairs(PlayerInRound) do
- local progress = playerInRound:FindFirstChild("RoundProgress")
- if not progress then
- progress = Instance.new("IntValue")
- progress.Name = "RoundProgress"
- progress.Parent = playerInRound
- end
- progress.Value = progress.Value + quantity
- playerInRound.PlayerGui.ShowRound.Frame.TextLabel.Text = "Progress: " .. progress.Value .. "/" .. roundInfo[zombieType]
- -- Reward players based on their progress
- if progress.Value == roundInfo[zombieType] then
- playerInRound:FindFirstChild("Stats"):FindFirstChild("Currency").Value = playerInRound.Stats.Currency.Value + 10
- playerInRound.PlayerGui.ShowRound.Frame.TextLabel.Text = "Reward: 10 Coins!"
- progress.Value = 0 -- Reset progress after reward
- end
- end
- end
- end
- -- NPC behavior
- local function enhanceNpcBehavior(npc)
- -- Random chance to trigger a special attack
- local specialAttackChance = math.random(1, 5)
- if specialAttackChance == 1 then
- local specialAttack = Instance.new("Part")
- specialAttack.Size = Vector3.new(5, 1, 5)
- specialAttack.Position = npc.HumanoidRootPart.Position + Vector3.new(0, 10, 0)
- specialAttack.Anchored = true
- specialAttack.BrickColor = BrickColor.new("Bright red")
- specialAttack.Parent = workspace
- game:GetService("Debris"):AddItem(specialAttack, 3)
- print("Special attack triggered by " .. npc.Name)
- -- Apply damage to players in range of the special attack
- for _, player in pairs(workspace.Players:GetChildren()) do
- if player.Character and (player.Character.HumanoidRootPart.Position - specialAttack.Position).Magnitude < 10 then
- player.Character.Humanoid:TakeDamage(50) -- Deal 50 damage
- print(player.Name .. " took damage from special attack!")
- end
- end
- end
- end
- -- Handle player interaction with teleporter zones and special zones
- for i, container in pairs(TeleportZones.SuburanSiegeTeleporter:GetChildren()) do
- local Timer = BaseTimer
- local Owner
- local EnteredPlayer = {}
- local PlayerInRound = {}
- local Connection = nil
- EndRound.ShouldEndSubrubanRounds = false
- if container:IsA("BasePart") then
- local zone = ZoneModule.new(container)
- zone.playerEntered:Connect(function(player)
- table.insert(EnteredPlayer, player)
- container.PlayersUI.BillboardGui.TextLabel.Text = #EnteredPlayer.."/"..MinimumPlayerRequired
- if not Owner then
- Owner = player
- Timer = BaseTimer
- while Timer >= 0 do
- if not Owner then break end
- print(Timer)
- wait(1)
- Timer -= 1
- end
- if not Owner then return end
- print("Timer Finished")
- for _, PlayerToTeleport : Player in pairs(EnteredPlayer) do
- table.insert(PlayerInRound, PlayerToTeleport)
- PlayerToTeleport.Character.PrimaryPart.CFrame = SuburbanSiege.SpawnPoints:GetChildren()[math.random(1, #SuburbanSiege.SpawnPoints:GetChildren())].CFrame
- PlayerToTeleport.PlayerGui.ShowRound.Enabled = true
- end
- Connection = nil
- end
- SuburbanSiege.CurrentDamage.Value = 0
- EndRound.ShouldEndSubrubanRounds = false
- if container.Name == "EasyZone" then
- spawn(function()
- HandleRounds(Connection, PlayerInRound, EasyRoundLenght, "EasyRound")
- end)
- elseif container.Name == "MediumZone" then
- spawn(function()
- HandleRounds(Connection, PlayerInRound, MediumRoundLenght, "MediumRound")
- end)
- elseif container.Name == "HardZone" then
- spawn(function()
- HandleRounds(Connection, PlayerInRound, EasyRoundLenght, "HardRound")
- end)
- elseif container.Name == "ExtremeZone" then
- spawn(function()
- HandleRounds(Connection, PlayerInRound, EasyRoundLenght, "ExtremeRound")
- end)
- end
- end)
- zone.playerExited:Connect(function(player)
- local find = table.find(EnteredPlayer, player)
- table.remove(EnteredPlayer, find)
- if player == Owner then
- Owner = nil
- end
- container.PlayersUI.BillboardGui.TextLabel.Text = #EnteredPlayer.."/"..MinimumPlayerRequired
- end)
- end
- end
- -- Monitor and notify if any player exceeds the maximum rounds played
- local function monitorMaxRounds(PlayerInRound)
- for _, player in pairs(PlayerInRound) do
- local roundsPlayed = player:FindFirstChild("RoundsPlayed")
- if not roundsPlayed then
- roundsPlayed = Instance.new("IntValue")
- roundsPlayed.Name = "RoundsPlayed"
- roundsPlayed.Parent = player
- end
- if roundsPlayed.Value >= 5 then
- player:Kick("You have exceeded the maximum number of rounds allowed!")
- print(player.Name .. " has been kicked for exceeding max rounds played.")
- end
- end
- end
- -- Call function to track progress for each round
- for i, container in pairs(TeleportZones.SuburanSiegeTeleporter:GetChildren()) do
- local Timer = BaseTimer
- local Owner
- local EnteredPlayer = {}
- local PlayerInRound = {}
- monitorMaxRounds(PlayerInRound)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement