Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --handles medals and king of the hill announcements
- --handle audio files(Thanks halo multiplayer announcer)
- game.ReplicatedStorage.Gamemodeparts["Announcer Voices"].Parent = game.Workspace
- game.ReplicatedStorage.Gamemodeparts["VIPmessages"].Parent = game.Workspace
- local Players = game:GetService("Players")
- --Lets go through EACH player and add a number value called "Swordkills"
- Players.PlayerAdded:Connect(function(player)
- for i, v in pairs(game.Players:GetChildren()) do
- local doesexist = v:FindFirstChild("Swordkills")
- if(doesexist == false or doesexist == nil) then
- local test = Instance.new("NumberValue")
- test.Parent = v
- test.Name = "Swordkills"
- test.Value = 0
- local test = Instance.new("NumberValue")
- test.Parent = v
- test.Name = "Hammerkills"
- test.Value = 0
- end
- end
- --sometimes if the player kills himself during VIP the owner tag will still be there, this will fix that and add a new vip
- player.CharacterAdded:Connect(function(character)
- character:WaitForChild("Humanoid").Died:Connect(function()
- if(game.ReplicatedStorage.Gamemodeparts.Gamemode.Value == "VIP") then
- --hacky fix but if it works it works
- wait(8)
- if(player:FindFirstChild("Owner")) then
- player.Owner:Destroy()
- --find a new VIP
- game.Workspace.VIPmessages.PlaybackRegionsEnabled = true
- game.Workspace.VIPmessages.PlaybackRegion = NumberRange.new(0, 1.730)
- game.Workspace.VIPmessages:Play()
- --get a random teen
- local players = game:GetService("Players"):GetPlayers()
- local randomteen = players[math.random(1, #players)]
- --add the billboard GUI to him
- local Killthevip = game.ReplicatedStorage.Gamemodeparts.KilltheVIP:Clone()
- Killthevip.Parent = randomteen.Character.Head
- --create label to let weapons know this is the VIP onkill
- local VIPholder = Instance.new("BoolValue", randomteen.Character)
- VIPholder.Name = "VIPholder"
- local ownerTag = Instance.new("BoolValue")
- ownerTag.Name = "Owner"
- ownerTag.Value = true
- ownerTag.Parent = randomteen
- end
- end
- end)
- end)
- end)
- --handle what happens when a player leaves during VIP
- Players.PlayerRemoving:Connect(function(playerLeaving)
- if(game.ReplicatedStorage.Gamemodeparts.Gamemode.Value == "VIP") then
- if(playerLeaving:FindFirstChild("Owner")) then
- -- Get valid VIP candidates
- local players = Players:GetPlayers()
- local potentialVIPs = {}
- for _, player in ipairs(players) do
- local hasCantBeVIP = player:FindFirstChild("CantBeVIP")
- or (player.Character and player.Character:FindFirstChild("CantBeVIP"))
- if not hasCantBeVIP then
- table.insert(potentialVIPs, player)
- end
- end
- -- Handle case where no valid VIPs exist
- if #potentialVIPs == 0 then
- warn("[VIP] No valid players for VIP selection.")
- return
- end
- -- Pick one at random
- local newVIP = potentialVIPs[math.random(1, #potentialVIPs)]
- -- Setup billboard GUI
- local billboard = game.ReplicatedStorage.Gamemodeparts.KilltheVIP:Clone()
- billboard.Parent = newVIP.Character:WaitForChild("Head")
- -- VIP marker for weapons to detect
- local vipTag = Instance.new("BoolValue")
- vipTag.Name = "VIPholder"
- vipTag.Parent = newVIP.Character
- -- Owner tag for consistency
- local ownerTag = Instance.new("BoolValue")
- ownerTag.Name = "Owner"
- ownerTag.Value = true
- ownerTag.Parent = newVIP
- end
- end
- end)
- local ReplicatedStore = game:GetService("ReplicatedStorage")
- local TweenService = game:GetService("TweenService")
- local touching = workspace:WaitForChild("touching")
- local hillVisual = workspace:WaitForChild("hill")
- local announce = ReplicatedStore:WaitForChild("SendMessage") -- RemoteEvent
- local hillOccupants = {}
- local debounce = {}
- -- encode a Color3 to "r,g,b"
- local function encodeColor(c)
- return string.format("%d,%d,%d", math.floor(c.R*255), math.floor(c.G*255), math.floor(c.B*255))
- end
- local function encodeColor2(R, G, B)
- return string.format("%d,%d,%d", R, G, B)
- end
- --Handle when the player dies and reset their killstreaks
- game:GetService("Players").PlayerAdded:Connect(function(player)
- player.CharacterAdded:Connect(function(character)
- character:WaitForChild("Humanoid").Died:Connect(function()
- wait(5)
- player.Swordkills.Value = 0
- player.Hammerkills.Value = 0
- end)
- end)
- end)
- --Handle when the bindable event gets called telling us about a new kill
- game.ReplicatedStorage.KillCall.Event:Connect(function(plr, weapon, victim, specialattributes)
- local newC = encodeColor2(0, 255, 0)
- local NumberKills = plr.Swordkills.value
- local victimPlayer = Players:GetPlayerFromCharacter(victim)
- print("Doing event")
- --handle medals that are not realated to the weapon that was being held like weapon related killstreaks like the killjoy
- if(victimPlayer ~= nil) then
- print("VictimPlayer".. victimPlayer.Name)
- print("Instanced")
- --Handle instance of a killjoy
- if(victimPlayer:FindFirstChild("Swordkills").value > 4 or victimPlayer:FindFirstChild("Hammerkills").value > 4) then
- local Killjoycolor = encodeColor2(255, 255, 0)
- print("killjoy")
- announce:FireAllClients{
- Text = " KILLJOY: ".. plr.Name .. " ended ".. victimPlayer.Name "s ".. tostring(victimPlayer.Hammerkills.Value + victimPlayer.Swordkills.value) " Killstreak.",
- Metadata = newC
- }
- else
- print("Value for failed killjoy: ".. victimPlayer.Swordkills.value)
- end
- end
- --Handle instance of a survivor
- if plr.Character.Humanoid.Health < 31 then
- task.spawn(function()
- local humanoid = plr.Character:FindFirstChild("Humanoid")
- if not humanoid then return end
- local startTime = tick()
- while tick() - startTime < 30 do
- if humanoid.Health <= 0 then
- -- Player died before 30 seconds
- return
- end
- task.wait(1) -- check every second (adjust if needed)
- end
- -- 30 seconds passed, player is still alive
- local newC = encodeColor2(0, 255, 0)
- announce:FireAllClients{
- Text = " SURVIVOR: ".. plr.Name .. " Survived a enouncter with extremely low health and came out on top",
- Metadata = newC
- }
- end)
- end
- --handle instance of a yoink
- if(specialattributes == "Lunging") then
- local newC = encodeColor2(255, 255, 0)
- announce:FireAllClients{
- Text = " Yoink: ".. plr.Name .. "Killed a enemy while they were lunging",
- Metadata = newC
- }
- end
- if(weapon == "Sword") then
- local newC = encodeColor2(0, 255, 0)
- if(NumberKills == 5) then
- print("5 KILSTREAK")
- announce:FireAllClients{
- Text = " >Just waiting for a proper soyduel. ".. plr.Name .. " has gotten 5 kills with the Dual Greentext arrows ",
- Metadata = newC
- }
- else if(NumberKills == 10) then
- print("10 KILSTREAK")
- announce:FireAllClients{
- Text = " >finally a worthy opponent, our battle will be LEGENDARY. ".. plr.Name .. " has gotten 10 kills with the Dual Greentext arrows ",
- Metadata = newC
- }
- end
- if(NumberKills == 15) then
- print("10 KILSTREAK")
- announce:FireAllClients{
- Text = " >Make sure to remember the arrow. ".. plr.Name .. " has gotten 15 kills with the Dual Greentext arrows ",
- Metadata = newC
- }
- end
- if(NumberKills == 20) then
- print("10 KILSTREAK")
- announce:FireAllClients{
- Text = " >You see that, You say and look like that.".. plr.Name .. " has gotten 20 kills with the Dual Greentext arrows. HES UNSTOPPABLE",
- Metadata = newC
- }
- end
- end
- end
- if(weapon == "Hammer") then
- local newC = encodeColor2(255, 0, 255)
- if(NumberKills == 5) then
- print("5 KILSTREAK")
- announce:FireAllClients{
- Text = " STOP... Hammer time".. plr.Name .. " has gotten 5 kills with the Janny Hammer",
- Metadata = newC
- }
- else if(NumberKills == 10) then
- print("10 KILSTREAK")
- announce:FireAllClients{
- Text = " Controlfreak Feared Tryant".. plr.Name .. " has gotten 10 kills with the Janny Hammer ",
- Metadata = newC
- }
- end
- if(NumberKills == 15) then
- print("10 KILSTREAK")
- announce:FireAllClients{
- Text = "Banwave...".. plr.Name .. " has gotten 15 kills with the Janny Hammer. ",
- Metadata = newC
- }
- end
- if(NumberKills == 20) then
- print("10 KILSTREAK")
- announce:FireAllClients{
- Text = " Jay Irwin ".. plr.Name .. " Is Unfair, Power Hungry, and has a thirst for slaughter." .. plr.Name " IS ON A 20 KILLSTREAK WITH THE JANNY HAMMER" ,
- Metadata = newC
- }
- end
- end
- end
- end)
- --KING OF THE HILL MANAGER
- local currentOwner = nil -- tracks who currently owns the hill
- local function isOnHill(p) return hillOccupants[p] end
- local function tweenColor(fromColor, toColor, duration)
- TweenService:Create(hillVisual,
- TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut),
- { Color = toColor }
- ):Play()
- end
- local function showHillGUI(plr)
- local gui = plr:FindFirstChild("PlayerGui")
- if not gui then return end
- local textbox = gui:FindFirstChild("Hill") and gui.Hill:FindFirstChild("TextBox")
- if not textbox then return end
- local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
- local goal = { Position = UDim2.new(1, -500, 1, -50) }
- TweenService:Create(textbox, tweenInfo, goal):Play()
- end
- local function hideHillGUI(plr)
- local gui = plr:FindFirstChild("PlayerGui")
- if not gui then return end
- local textbox = gui:FindFirstChild("Hill") and gui.Hill:FindFirstChild("TextBox")
- if not textbox then return end
- local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
- local goal = { Position = UDim2.new(1, 6, 1, -50) }
- TweenService:Create(textbox, tweenInfo, goal):Play()
- end
- local function HandleHill(hit)
- local char = hit.Parent
- if not char then return end
- local hum = char:FindFirstChild("Humanoid")
- if not hum then return end
- local plr = Players:GetPlayerFromCharacter(char)
- if not plr or debounce[plr] then return end
- debounce[plr] = true
- hillOccupants[plr] = true
- local newColor = plr.TeamColor.Color
- -- Only change if they don't already own it
- if currentOwner ~= plr then
- -- Remove Owner tag from previous owner
- if currentOwner and currentOwner:FindFirstChild("Owner") then
- currentOwner.Owner:Destroy()
- hideHillGUI(currentOwner)
- end
- -- Set new owner marker
- if not plr:FindFirstChild("Owner") then
- local ownerTag = Instance.new("BoolValue")
- ownerTag.Name = "Owner"
- ownerTag.Value = true
- ownerTag.Parent = plr
- end
- showHillGUI(plr)
- local oldColor = currentOwner and currentOwner.TeamColor.Color or Color3.new(1,1,1)
- tweenColor(oldColor, newColor, 3)
- if currentOwner == nil then
- announce:FireAllClients{
- Text = plr.Team.Name .. " controls the Hill! 2× cash for them.",
- Metadata = encodeColor(newColor)
- }
- else
- announce:FireAllClients{
- Text = plr.Name .. " is contesting the hill...",
- Metadata = encodeColor(newColor)
- }
- task.delay(3, function()
- if isOnHill(plr) then
- currentOwner = plr
- touching:SetAttribute("FirstServed", plr.Name)
- hillVisual.Color = newColor
- announce:FireAllClients{
- Text = plr.Team.Name .. " now controls the Hill! 2× cash for them.",
- Metadata = encodeColor(newColor)
- }
- end
- end)
- return
- end
- currentOwner = plr
- touching:SetAttribute("FirstServed", plr.Name)
- end
- task.delay(1, function()
- debounce[plr] = nil
- end)
- end
- function switchtovip()
- -- Make hill inactive
- game.Workspace.hill.Transparency = 1
- game.Workspace.touching.CanTouch = false
- -- Play voice line
- local messages = game.Workspace.VIPmessages
- messages.PlaybackRegionsEnabled = true
- messages.PlaybackRegion = NumberRange.new(0, 1.730)
- messages:Play()
- -- Clean up current VIP
- if currentOwner then
- if currentOwner:FindFirstChild("Owner") then
- currentOwner.Owner:Destroy()
- end
- hideHillGUI(currentOwner)
- end
- -- Get valid VIP candidates
- local players = Players:GetPlayers()
- local potentialVIPs = {}
- for _, player in ipairs(players) do
- local hasCantBeVIP = player:FindFirstChild("CantBeVIP")
- or (player.Character and player.Character:FindFirstChild("CantBeVIP"))
- if not hasCantBeVIP then
- table.insert(potentialVIPs, player)
- end
- end
- -- Handle case where no valid VIPs exist
- if #potentialVIPs == 0 then
- warn("[VIP] No valid players for VIP selection.")
- return
- end
- -- Pick one at random
- local newVIP = potentialVIPs[math.random(1, #potentialVIPs)]
- -- Setup billboard GUI
- local billboard = game.ReplicatedStorage.Gamemodeparts.KilltheVIP:Clone()
- billboard.Parent = newVIP.Character:WaitForChild("Head")
- -- VIP marker for weapons to detect
- local vipTag = Instance.new("BoolValue")
- vipTag.Name = "VIPholder"
- vipTag.Parent = newVIP.Character
- -- Owner tag for consistency
- local ownerTag = Instance.new("BoolValue")
- ownerTag.Name = "Owner"
- ownerTag.Value = true
- ownerTag.Parent = newVIP
- end
- local function cleanUpValues()
- for _, player in ipairs(Players:GetPlayers()) do
- local ownerValue = player:FindFirstChild("Owner")
- if ownerValue then
- ownerValue:Destroy()
- end
- if player.Character then
- local vipHolder = player.Character:FindFirstChild("VIPholder")
- if vipHolder then
- vipHolder:Destroy()
- end
- local Vipbillboard = player.Character.Head:FindFirstChild("KilltheVIP")
- if Vipbillboard then
- Vipbillboard:Destroy()
- end
- end
- end
- end
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- function makesuresoylentexist()
- while true do
- if ReplicatedStorage.Gamemodeparts.Gamemode.Value ~= "Soylentball" then return end
- task.wait(1)
- local soylents = {} -- List to store all found soylent instances
- for _, obj in ipairs(workspace:GetChildren()) do
- if obj.Name == "Soylent" then
- table.insert(soylents, obj)
- end
- end
- for _, player in ipairs(Players:GetPlayers()) do
- local bpSoylent = player:FindFirstChild("Backpack") and player.Backpack:FindFirstChild("Soylent")
- if bpSoylent then
- table.insert(soylents, bpSoylent)
- end
- local charSoylent = player.Character and player.Character:FindFirstChild("Soylent")
- if charSoylent then
- table.insert(soylents, charSoylent)
- end
- end
- if #soylents > 1 then
- print("[WARN] More than 1 Soylent detected! Count:", #soylents)
- for i = #soylents, 2, -1 do
- local j = math.random(1, i)
- soylents[i], soylents[j] = soylents[j], soylents[i]
- end
- for i = 2, #soylents do
- if soylents[i] and soylents[i].Parent then
- soylents[i]:Destroy()
- end
- end
- elseif #soylents == 0 then
- local clone = ReplicatedStorage:FindFirstChild("Soylent")
- if clone then
- local new = clone:Clone()
- new.Parent = workspace
- if workspace:FindFirstChild("hill") then
- workspace.hill.Transparency = 1
- end
- if workspace:FindFirstChild("touching") then
- workspace.touching.CanTouch = false
- end
- else
- warn("Soylent not found in ReplicatedStorage")
- end
- end
- end
- end
- function setupsoylentball()
- local clone = game.ReplicatedStorage.Soylent:Clone()
- clone.Parent = game.Workspace
- game.Workspace.hill.Transparency = 1
- game.Workspace.touching.CanTouch = false
- end
- game.ReplicatedStorage.Gamemodeparts.Vipchange.Event:Connect(function(Player, Player2)
- Player2.Character.Head.KilltheVIP:Destroy()
- Player2.Owner:Destroy()
- game.Workspace.VIPmessages.PlaybackRegionsEnabled = true
- game.Workspace.VIPmessages.PlaybackRegion = NumberRange.new(1.730, 3.683)
- game.Workspace.VIPmessages:Play()
- local VIPholder = Instance.new("BoolValue", Player.Character)
- VIPholder.Name = "VIPholder"
- local ownerTag = Instance.new("BoolValue")
- ownerTag.Name = "Owner"
- ownerTag.Value = true
- ownerTag.Parent = Player
- local Killthevip = game.ReplicatedStorage.Gamemodeparts.KilltheVIP:Clone()
- Killthevip.Parent = Player.Character.Head
- end)
- touching.Touched:Connect(function(hit)
- local char = hit.Parent
- local plr = Players:GetPlayerFromCharacter(char)
- if plr then
- HandleHill(hit)
- end
- end)
- wait(18)
- --start message on start of server
- announce:FireAllClients{
- Text = "Welcome. Current Gamemode rotation is King of the hill VIP, and Soylentball",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- while true do
- if(game.ReplicatedStorage.Settings["Gamemode settings"].IncludeKingoftheHillinrotation.Value == true ) then
- cleanUpValues()
- game.ReplicatedStorage.Gamemodeparts.Gamemode.Value = "King of the hill"
- game.Workspace.hill.Transparency = 0
- game.Workspace.touching.CanTouch = true
- task.wait(60)
- announce:FireAllClients{
- Text = "4 Mintues Remaing on King of the Hill",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- task.wait(120)
- announce:FireAllClients{
- Text = "Gamemode will switch to VIP in two minutes",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- task.wait(120)
- announce:FireAllClients{
- Text = "King of the Hill is over, Its VIP time.",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- end
- if(game.ReplicatedStorage.Settings["Gamemode settings"].IncludeVIPinrotation.Value == true ) then
- game.ReplicatedStorage.Gamemodeparts.Gamemode.Value = "VIP"
- switchtovip()
- task.wait(60)
- announce:FireAllClients{
- Text = "VIP is ending in 4 minutes.",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- task.wait(120)
- announce:FireAllClients{
- Text = "VIP is almost over, Soylent Ball will be chosen for the next gamemode in two minutes.",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- task.wait(120)
- announce:FireAllClients{
- Text = "VIP is over, Soylent Ball is the new gamemode.",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- cleanUpValues()
- end
- if(game.ReplicatedStorage.Settings["Gamemode settings"].IncludeSoylentballinrotation.Value == true) then
- game.ReplicatedStorage.Gamemodeparts.Gamemode.Value = "Soylentball"
- task.delay(0, makesuresoylentexist())
- setupsoylentball()
- task.wait(60)
- announce:FireAllClients{
- Text = "Soylent Ball is almost over, King of the Hill will be chosen for the next gamemode in 4 minutes.",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- task.wait(120)
- announce:FireAllClients{
- Text = "Soylent Ball is ending in 2 minutes.",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- task.wait(120)
- announce:FireAllClients{
- Text = "Soylent Ball is over, King of the hill is the new gamemode.",
- Metadata = encodeColor(Color3.new(1, 0, 0))
- }
- game.workspace["Announcer Voices"]:Play()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment