i keep trying to add to it on my test one but it breaks the whole game can soemone help me?....you dont have to send back the whoel script just tell me which lines to add it..its a long script

-- Setup

local GameClock = workspace:WaitForChild("GameClock")
local h = GameClock:WaitForChild("RoundText")
local round = 0
local currentMap = 0
local rep = game:GetService("ReplicatedStorage")
local mapData = rep:WaitForChild("MapData")

game.StarterGui.ResetPlayerGuiOnSpawn = false

-- Main Game Functions
 
function CountPlayers()
	-- Counts how many players are in the game
	-- If the game's JobId isn't set, this isn't a legitimate roblox server, 
	-- and therefore we return math.huge (infinity) to stop any loops.
	return game.JobId == "" and math.huge or #game.Players:GetPlayers()
end

function SetGameText(text)
	-- Sets the text to whatever 'text' is.
	h.Value = text
end

function WaitForPlayers(number)
	-- Waits until the number of players is greater or equal to number
	
	SetGameText("Waiting for " .. number .. " Players to start...")
	while CountPlayers() < number do
		game.Players.ChildAdded:wait()
	end
end

function WaitForRoundEnd()
	-- Waits until the GameClock value reaches 0.
	while GameClock.Time.Value > 0 do
		GameClock.Time.Changed:wait()
	end
end

function StartCountDownFrom(length)
	-- Starts the countdown clock.
	GameClock.Time.Value = length
	GameClock.Start:Invoke(true)
end

function ShowGameClock()
	-- Makes the clock invisible to players.
	-- Used when we're in a round
	GameClock.Visible.Value = true
end

function HideGameClock()
	-- Makes the clock invisible to players.
	-- Used when we aren't in a round
	GameClock.Visible.Value = false
end

function UnlockSpawning()
	-- Allows players to spawn and respawns everyone
	game.Players.CharacterAutoLoads = true
	for _,v in pairs(game.Players:GetPlayers()) do
		v:LoadCharacter(true)
	end
end

function DespawnPlayersAndLockSpawning()
	-- Prevents players from spawning and despawns everyone (they get put into a studio camera mode of a sort)
	game.Players.CharacterAutoLoads = false
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.Character then
			for _,x in pairs(v.Character:GetChildren()) do
				if x:IsA("Hat") or x:IsA("BasePart") or x:IsA("Tool") then
					x:Destroy()
				end
			end
		end
	end
end

function IncrementRound()
	-- Increases the round value by one, and updates the game text to display this.
	round = round + 1
	SetGameText("Round "..round)
end

function ResetScores()
	-- Sets the Score stat on all players to 0.
	for _,v in pairs(game.Players:GetPlayers()) do
		if v:findFirstChild("leaderstats") then
			if v.leaderstats:findFirstChild("Score") then
				v.leaderstats.Score.Value = 0
			end
		end
	end
end

function UnloadMap()
	-- Removes the current map
	if workspace:findFirstChild("Map") then
		workspace.Map:Destroy()
	end
	if game.Lighting:findFirstChild("Skybox") then
		game.Lighting.Skybox:Destroy()
	end
end

function MoveToNextMap()
	-- Selects the next map on the list based on the current map value.
	-- If the current map value is the number of maps, it gets reset to 1.
	-- From there, it will unload the previous map and load the new map into the game.
	-- Returns a next map message to be used by the game.
	currentMap = (currentMap == #mapData:GetChildren()) and 1 or currentMap + 1
	UnloadMap()
	-- Find the map that uses the current map value
	-- If the map value is 1, it will look for "Map1"
	local nextMap = mapData:findFirstChild("Map"..currentMap)
	local map = nextMap.Map:clone()
	map.Parent = workspace
	map:MakeJoints() -- Make sure nothing breaking into pieces.
	nextMap.Skybox:clone().Parent = game.Lighting -- Parent a copy of the skybox into the lighting
	return "Next Map: " .. nextMap.MapName.Value .. ", Get ready!" -- Return a message for the game to use
end

function IncrementStat(player,statName)
	-- Tries to increase an IntValue stat on a player.
	-- If you use this function on a stat that isn't an int value, the game will break. Be careful.
	if player:findFirstChild("leaderstats") then
		if player.leaderstats:findFirstChild(statName) then
			player.leaderstats[statName].Value = player.leaderstats[statName].Value + 1
		end
	end
end

function GetWinnerOrWinners()
	-- Returns "a winner player or a table of players who tied", and the highest score.
	local winner = nil
	local highestScore = 0
	for _,v in pairs(game.Players:GetPlayers()) do
		if v:findFirstChild("leaderstats") then
			if v.leaderstats:findFirstChild("Score") then
				if v.leaderstats.Score.Value > highestScore then
					-- Set the winner to this player
					winner = v
					highestScore = v.leaderstats.Score.Value
				elseif v.leaderstats.Score.Value == highestScore then
					-- We have multiple winners
					if type(winner) == "table" then
						-- There are already 2 winners. Just add it to the list
						table.insert(winner,v)
					else
						-- Turn the winner value into a table with the first winner, and this winner inside of it.
						winner = {winner,v}
					end
				end
			end
		end
	end
	return winner,highestScore
end

function WinnerText(winner,highestScore)
	-- Writes a string based on the winner and highest score
	if highestScore ~= 0 then
		if type(winner) == "table" then
			-- A bunch of people won. Try to display each of their names.
			local s = "There was a tie between "
			for i = 1,#winner do
				winner[i].leaderstats["Rounds Won"].Value = winner[i].leaderstats["Rounds Won"].Value + 1 
				if i == #winner then
					s = s.."and "..winner[i].Name
				else
					s = s..winner[i].Name..", "
				end
			end
			s = s .. " with " .. highestScore .. " kill(s)!"
			return s
		else
			IncrementStat(winner,"Rounds Won")
			return "The winner is: "..winner.Name.. " with " .. highestScore .. " kills(s)!"
		end
	else
		return "No winners this round :("
	end
end

-- Game Cycle.
 
while true do -- Infinite Loop
	
	NextMap = MoveToNextMap()
	
	WaitForPlayers(2)
	ResetScores()
	SetGameText(NextMap)
	
	Wait(2)
	
	IncrementRound()
	ShowGameClock()
	UnlockSpawning()
	
	StartCountDownFrom(300)
	WaitForRoundEnd()
	
	DespawnPlayersAndLockSpawning()
	SetGameText("GAME OVER!")
	HideGameClock()
	
	Wait(3)
	WinnerData,HighestScore = GetWinnerOrWinners()
	WinnerMessage = WinnerText(WinnerData,HighestScore)
	SetGameText(WinnerMessage)
	
	Wait(1)
	
end

3 comments

1

We will not edit your entire script for you. Post any errors and the part that is faulty, and we will suggest improvements. Thank you for your patience!

1

This is a request. This is not allowed. We will not go through over 200 lines to add a function to teleport for you. We could tell you how to do this and you could implement it, but you didn't ask for that.

0

like i said im not asking u to do the work for me..i said ive tried it but it didnt work so im wondering if you can show me or tell me how i dont want you to re write the 200 line script jeez..if you guys aint gonan help nvm then ill just keep trying..i dont know what type of help this site suppose to be