avatar
Untitled

Guest 97 11th Apr, 2024

MARKUP 3.98 KB
                                           
                         local roundTimer = 60 * 5
local serverstorage = game:GetService("ServerStorage")

local maps = serverstorage:WaitForChild("Maps")
local mapholder = game.Workspace:WaitForChild("MapHolder")

local replicatedstorage = game:GetService("ReplicatedStorage")
local statustag = replicatedstorage:WaitForChild("StatusTag")
local timertag = replicatedstorage:WaitForChild("TimerTag")
local event = replicatedstorage:WaitForChild("RemoteEvent")
local lobbyTimer = 20

while true do
	statustag.Value = "Loading Map"
	timertag.Value = -1
	mapholder:ClearAllChildren()
	wait(2)
	local allmaps = maps:GetChildren()
	local newmap = allmaps[math.random(1, #allmaps)]:clone()
	newmap.Parent = game.Workspace.MapHolder
	wait(2)
	while true do	
		wait(5)		
		statustag.Value = "Waiting for Players"
		timertag.Value = -1		
		count = {}
		for i, player in pairs(game.Players:GetPlayers()) do			
			table.insert(count, player)
		end
		if #count >=3 then
			break			
		end
	end
	
	statustag.Value = "Match"
	timertag.Value = roundTimer
	
	murder = count[math.random(1, #count)]
	while true do
		randomplayer = count[math.random(1, #count)]
		if randomplayer ~= murder then
			sheriff = randomplayer
			break
		end
	end
	
	local spawnsmodel = newmap:WaitForChild("Spawns")
	local spawns = spawnsmodel:GetChildren()
	for i, player in pairs(count) do
		if player and player.Character and #spawns > 0 then
			local RootPart = player.Character:WaitForChild("HumanoidRootPart")
			local spawnindex = math.random(1, #spawns)
			local spawn = spawns[spawnindex]
			if spawn and RootPart then
				table.remove(spawns, spawnindex)
				RootPart.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))		
				local matchtag = Instance.new("StringValue")
				matchtag.Name = "Match"
				matchtag.Parent = player.Character		
				local backpack = player:FindFirstChild("Backpack")				
				if backpack then
					if player == murder then
						local sword = serverstorage:WaitForChild("KodlandSword"):clone()
						sword.Parent = backpack
					elseif player == sheriff then
						local netgun = serverstorage:WaitForChild("NetKodland"):clone()
						netgun.Parent = backpack
					end
				end
			end
		end
	end
	spawnsmodel:remove()	
	
	local localtimer = roundTimer
	while localtimer > 0 do
		wait(1)	
		localtimer = localtimer - 1
		timertag.Value = localtimer		
		activeplayers = {}
		murderactive = false		
		for i, player in pairs(count) do			
			local character = player.Character		
			local matchtag = character:FindFirstChild("Match")
			local humanoid = character:FindFirstChild("Humanoid")
			if matchtag and humanoid.Health > 0 then
				if player == murder then
					murderactive = true
				end
				table.insert(activeplayers, player)						
			end	
		end		
		if #activeplayers <= 1 or not murderactive then
			break
		end	
	end

	local lobbyspawns = {}
	for i, teleports in pairs(game.Workspace:WaitForChild("Lobby"):GetChildren()) do
		if teleports.Name == "SpawnLocation" then
			table.insert(lobbyspawns, teleports)
		end
	end	
	for i, player in pairs(activeplayers) do			
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid:UnequipTools()
		end			
		local randomspawn = lobbyspawns[math.random(1, #lobbyspawns)]
		player.Character:MoveTo(randomspawn.Position)
		
		local backpack = player:FindFirstChild("Backpack")
		if backpack then
			backpack:ClearAllChildren()
		end	
		
	end	

	statustag.Value = "Intermission"
	timertag.Value = lobbyTimer
	local localtimer = lobbyTimer
	while localtimer > 0 do
		wait(1)
		localtimer = localtimer - 1
		timertag.Value = localtimer
	end	
end
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
Ta strona używa plików cookie w celu usprawnienia i ułatwienia dostępu do serwisu oraz prowadzenia danych statystycznych. Dalsze korzystanie z tej witryny oznacza akceptację tego stanu rzeczy.
Wykorzystywanie plików Cookie
Jak wyłączyć cookies?
ROZUMIEM