How to make a tag game with map voting?

Hello!

I was thinking of making a new project, i want it to be a short a quick tag game with map voter and a round system.

Only problem is that i don’t know how to make one! I would like to hear how to set it up because im still learning the lua code language!

Any ideas or comments?

Cheers! :wink:

I would recommend watching some tutorials on You-Tube by Alvin Blox. He has a video on a round system (For a sword fighting game a believe.) And also a map voting system tutorial.

2 Likes

I would recommend this video.
How to Make a Voting System in Roblox Studio - YouTube
If you dont care about voting, it’s easy to spawn maps out of ReplicatedStorage, using math.random. Here’s some example code, with no voting.

local waitTime = 10
local Maps = game.ReplicatedStorage
local playTime = 120
local chance = math.random(1,#Maps)

if chance == 1 then
local new = Maps.Name:Clone()
new.Parent = game.Workspace.Map
new.Name = "MinigameName"
task.wait(playTime)
new:Destroy()
chance = math.random(1,#Maps)
return
elseif chance == 2 then
--Same code
end

That SHOULD work in a script in workspace, lmk.

2 Likes

Well, you’ll need to make a map folder in rep storage. Put maps in there. This is my game’s map voting thing. Just an example on what you should try to do when making a map voting.

local function StartVotingProcess()
	local VotingMaps = game.ReplicatedStorage.Maps:GetChildren()
	print("Voting has started!")
	local Map1Votes = game.ReplicatedStorage.Votes.Map1
	local Map2Votes = game.ReplicatedStorage.Votes.Map2
	local Map3Votes = game.ReplicatedStorage.Votes.Map3
	Map1Votes.Value = 0
	Map2Votes.Value = 0
	Map3Votes.Value = 0
	for i,v in pairs(game.Players:GetPlayers()) do
		if v:IsA("Player") then
			v.GameStats.VotedFor.Value = nil
			v.GameStats.Voted.Value = false
		end
	end
	local RandomNumber1 = math.random(1, #VotingMaps)
	ChosenMap1 = VotingMaps[RandomNumber1]
	table.remove(VotingMaps, RandomNumber1)
	local RandomNumber2 = math.random(1, #VotingMaps)
ChosenMap2 = VotingMaps[RandomNumber2]
	table.remove(VotingMaps, RandomNumber2)
	local RandomNumber3 = math.random(1, #VotingMaps)
 ChosenMap3 = VotingMaps[RandomNumber3]
	table.remove(VotingMaps, RandomNumber3)
	for i,v in pairs(game.Players:GetPlayers()) do
		if v:IsA("Player") then
			local VotingFrame = v.PlayerGui:WaitForChild("VotingGui").VotingFrame
		game.ReplicatedStorage.RemoteEvents.MoveVotingGuiEvent:FireClient(v, VotingFrame, true)
			VotingFrame.Map1.Image = ChosenMap1.MapImage.Image
			VotingFrame.Map1.MapName.Text = ChosenMap1.DisplayName.Value
			VotingFrame.Map2.Image = ChosenMap2.MapImage.Image
			VotingFrame.Map2.MapName.Text = ChosenMap2.DisplayName.Value
			VotingFrame.Map3.MapName.Text = ChosenMap3.DisplayName.Value
			VotingFrame.Map3.Image = ChosenMap3.MapImage.Image
		end
	end
	local MapWithMostVotes
	for VotingTime = 25, 0, -1 do
		Status.Value = "Voting! Time remaining: " .. VotingTime
		wait(1)
	end
	local VotingAmountsTable = {}
	table.insert(VotingAmountsTable, Map1Votes.Value)
	table.insert(VotingAmountsTable,Map2Votes.Value)
	table.insert(VotingAmountsTable,Map3Votes.Value)
	
	
	local HighestAmount = nil
	for i,v in pairs(game.Players:GetPlayers()) do
		print(v.Name)
		if v:IsA("Player") then

			local VotingFrame = v.PlayerGui:WaitForChild("VotingGui").VotingFrame
			game.ReplicatedStorage.RemoteEvents.MoveVotingGuiEvent:FireClient(v, VotingFrame, false)
		end
	end
	for _, value in pairs(VotingAmountsTable) do
		if not HighestAmount then
			HighestAmount = value
			continue
		end

		if value > HighestAmount then
			HighestAmount = value
		end
	end
	local MapWithMostVotes = nil
	if Map1Votes.Value == HighestAmount then
		
	return ChosenMap1
			
	elseif Map2Votes.Value == HighestAmount then
	
		return ChosenMap2
	elseif Map3Votes.Value == HighestAmount then
		
		return ChosenMap3
	end
end
2 Likes

I would put your maps in a folder in ServerStorage called maps, then add a Script in ServerScriptService something like this for now:


local function intermission() -- If you want
    local countdownGUI = pathToYourIntermissionGUIText
    local timer = game.ReplicatedStorage.Clock

    repeat wait(1)
        countdownGUI.Text = timer.Value
        timer.Value -= 1
    until timer.Value == 0

    countdownGUI.Text = "Voting begining!"
end

local function voting() -- This may vary depending on your system (maybe you can try @kinglol's function here)

    return chosenMap -- This is necessary
end

local function game()
    intermission()
    local chosenMap = voting()

    local map = game.ServerStorage[chosenMap]:Clone()
    map.Name = "Map"
    map.Parent = game.Workspace

    --The round handling will go here!
end

while wait() do
    if #game.Players:GetChildren() >= 2 then -- 2 Or more players
        game()
    else
        repeat wait(1) until #game.Players:GetChildren() >= 2
    end
end

Also make sure you have and IntValue in ReplicatedStorage called Clock

2 Likes

Yeah sorry, if anybody uses my response then use the while task.wait() do thing here i forgot it lol

1 Like