Hello everyone, I'm trying to make a map voting system! When I run the script, the randomize ( happend when there is a tie!) still working good! It printed out the choosen map and clone it into the workspace! But when I vote one map, it didnt print or clone, it just skip and go to in-round immediately! Can anyone help me? This is my script : Status Script ( SSS )
local statusLabel = script.Parent:WaitForChild("StatusLabel")
local VotingSystem = game.Workspace:WaitForChild("VotingSystem")
local Maps = VotingSystem.Maps
local Pad1 = Maps:WaitForChild("Pad1")
local Pad2 = Maps:WaitForChild("Pad2")
local Pad3 = Maps:WaitForChild("Pad3")
local rep = game:GetService("ReplicatedStorage")
local doneVoting = rep.VotingCompleted
local votingTime = rep.VotingTime
local function CalculateWinner()
local padVotes = {
["Green Map"] = Pad1.Votes.Value,
["Red Map"] = Pad2.Votes.Value,
["Blue Map"] = Pad3.Votes.Value,
}
local highest = 0
local pad = nil
for i, v in pairs(padVotes) do
if v > highest then
print(highest)
highest = v
pad = i
end
end
return pad
end
doneVoting.Changed:Connect(function()
local randomMap = VotingSystem.Maps:GetChildren()
local choosenMap = CalculateWinner()
if choosenMap == nil then
if game.ReplicatedStorage.InGame.Value == false then
local randomChoosenMap = randomMap[math.random(1, #randomMap)]
statusLabel.Text = "Loading "..randomChoosenMap:WaitForChild("Name").Value.."..."
local cloneRandomMap = game.ServerStorage.MapStorage:FindFirstChild(randomChoosenMap:WaitForChild("Name").Value):Clone()
cloneRandomMap.Name = "CurrentMap"
cloneRandomMap.Parent = workspace
elseif choosenMap ~= nil then
if game.ReplicatedStorage.InGame.Value == false then
statusLabel.Text = "Loading "..choosenMap.."..."
local cloneChoosenMap = game.ServerStorage.MapStorage:FindFirstChild(choosenMap):Clone()
cloneChoosenMap.Name = "CurrentMap"
cloneChoosenMap.Parent = workspace
else
print("An error just happend!")
end
end
end
end)
Text Script ( Placed in the Status Text in the StarterGui! )
local VotingSystem = game.Workspace:WaitForChild("VotingSystem")
local Maps = VotingSystem.Maps
local Pad1 = Maps:WaitForChild("Pad1")
local Pad2 = Maps:WaitForChild("Pad2")
local Pad3 = Maps:WaitForChild("Pad3")
local MapDisplay = VotingSystem.MapDisplay
local rep = game:GetService("ReplicatedStorage")
local doneVoting = rep.VotingCompleted
local votingTime = rep.VotingTime
game.Players.PlayerAdded:Connect(function(plr)
local vote = Instance.new("StringValue")
vote.Name = "Vote"
vote.Parent = plr
vote.Value = "NA"
end)
local function updateDisplay()
MapDisplay.Vote1.SurfaceGui.VoteCount.Text = "Votes : "..Pad1.Votes.Value
MapDisplay.Vote2.SurfaceGui.VoteCount.Text = "Votes : "..Pad2.Votes.Value
MapDisplay.Vote3.SurfaceGui.VoteCount.Text = "Votes : "..Pad3.Votes.Value
end
for i, Pad in pairs(game.Workspace.VotingSystem.Maps:GetChildren()) do
if Pad.Name ~= "MapDisplay" then
Pad.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
if plr.Vote.Value ~= Pad then
Pad.Votes.Value = Pad.Votes.Value + 1
if plr.Vote.Value ~= "NA" then
local padToSubtract = VotingSystem.Maps:FindFirstChild(plr.Vote.Value)
padToSubtract.Votes.Value = padToSubtract.Votes.Value - 1
end
plr.Vote.Value = Pad.Name
updateDisplay()
end
end
end)
end
end
spawn(function()
while wait() do
for i = 10,1,-1 do
wait(1)
for _,playerGui in pairs(game.Players:GetPlayers()) do
playerGui.PlayerGui:WaitForChild("ServerStatus"):FindFirstChild("StatusLabel").Text = "Intermission : "..i
end
end
for _,players in pairs(game.Players:GetPlayers()) do
players.Vote.Value = "NA"
Pad1:WaitForChild("Votes").Value = 0
Pad2:WaitForChild("Votes").Value = 0
Pad3:WaitForChild("Votes").Value = 0
updateDisplay()
doneVoting.Value = false
end
for i = 5,0,-1 do
wait(1)
for _,player in pairs(game.Players:GetPlayers()) do
votingTime.Value = 15
player.PlayerGui:WaitForChild("ServerStatus"):FindFirstChild("StatusLabel").Text = "Voting For Map..."
end
end
doneVoting.Value = true
for i = 15,1,-1 do
wait(1)
game.ReplicatedStorage.InGame.Value = true
for _,playerGui in pairs(game.Players:GetPlayers()) do
playerGui.PlayerGui:WaitForChild("ServerStatus"):FindFirstChild("StatusLabel").Text = "Game In Progress : "..i
end
end
doneVoting.Value = false
wait()
workspace:WaitForChild("CurrentMap"):Destroy()
for i = 5,0,-1 do
wait(1)
for _,playerGui in pairs(game.Players:GetPlayers()) do
playerGui.PlayerGui:WaitForChild("ServerStatus"):FindFirstChild("StatusLabel").Text = "Resetting Game..."
end
end
game.ReplicatedStorage.InGame.Value = false
end
end)

3 comments
You shouldn't clone the map. Just put the map in ServerStorage and if it won the vote, make the map's parent the workspace.
But the issue here is the text doesn’t change to Loading ( choosen map ), that’s the problem, it skip to game immediately
And it already won the map so the map won’t be a nil value!