Argument 1 missing or nil

Sup, imma making map voting and found strange error idk how description its just see error

17:20:50.540  Argument 1 missing or nil  -  Server - Round:15
17:20:50.541  Stack Begin  -  Studio
17:20:50.541  Script 'ServerScriptService.Main.Round', Line 15 - function LoadMap  -  Studio - Round:15
17:20:50.541  Script 'ServerScriptService.Main', Line 10  -  Studio - Main:10
17:20:50.541  Stack End  -  Studio

Round module script

function round.LoadMap()
	
	local votedMap = round.ToggleVoting()
	local mapFolder = SS.Maps:FindFirstChild(votedMap) -- 13 line
	
	if not mapFolder then
		mapFolder = SS.Maps.Grassland
	end
	
	local newMap = mapFolder:Clone()
	newMap.Parent = workspace.Map
	
	workspace.Spawn.Floor:Destroy()
	
	newMap.Base.Humanoid.HealthChanged:Connect(function(hp)
		if hp <= 0 then
			info.GameRunning.Value = false
			info.Messages.Value = "Game over, you can better!"
		end
	end)
	return newMap
end

function round.ProcessVote(player, vote)

	for name, mapVotes in pairs(votes) do
		local oldVote = table.find(mapVotes, player.UserId)
		if oldVote then
			table.remove(mapVotes, oldVote)
			print("Old vote found", oldVote)
			break
		end
	end
	print("Processed vote for".. vote)
	table.insert(votes[vote], player.UserId)
end


voteevent.OnServerEvent:Connect(round.ProcessVote)

function	 round.ToggleVoting()
	local maps = SS.Maps:GetChildren()
	votes = {}
	
	for i, map in ipairs(maps) do
		votes[map.Name] = {}
	end
	
	for i = 10, 1 -1 do
		info.Messages.Value = "Map voting ".. i 
		task.wait(1)
	end
	
	local winVote = nil
	local winScore = 0
	
	for name, map in pairs(votes) do
		if #map > winScore then
			winScore = #map
			winVote = name
		end
	end
	return winVote
end

Main script

local mob = require(script.Mob)
local tower = require(script.Tower)
local Players = game:GetService("Players")
local round = require(script.Round)
local ServerStorage = game:GetService("ServerStorage")
local bindables = ServerStorage:WaitForChild("Bindables")
local Update = bindables:WaitForChild("UpdateBaseHealth")
local GameOver = bindables:WaitForChild("GameOver")
local Player
local map = round.LoadMap() -- 10 line
local info = workspace.Info

i hope u ll help

You might want to try

local mapFolder = SS.Maps:FindFirstChild(votedMap.Name)

Or

if mapFolder == nil then
1 Like

if i shall try it .Name will index nil

Didnt help cause i tried it

Well i need to see more of the script, because i dont know what round.ToggleVoting() is in the script

Use breakpoints to watch your variables. I’m assuming winVote in ToggleVoting() is returned as nil.

Which is line 15 in the Round module? It doesn’t look like you posted the entire script.

thats correct but i assign its a meaning

for name, map in pairs(votes) do
		if #map > winScore then
			winScore = #map
			winVote = name
		end
	end

Thats 15 line, and all correct

It’s possible that winVote is nil, as @bluebxrrybot stated.

How does your ToggleVoting function work? It doesn’t look like it is actually getting votes from players.

Um Player clicks on ImageButton and RemoteEvent sends server thats anyone clicked on ImageButton and sends Name of buttton(and name of map cause name map = name of button)
then as soon as we got info from server event we writing player id and name of map which he voted for and finally for start game in main script, it requests info from Round module script

if you believe the output that yes

If winVote is nil, then no votes actually get sent to the ToggleVoting function. You have to somehow listen to the RemoteEvent you have.

Here’s a revised version of ToggleVoting. Rename voteRemoteEvent to the name of your RemoteEvent:

function	 round.ToggleVoting()
	local maps = SS.Maps:GetChildren()
	votes = {}

	for i, map in ipairs(maps) do
		votes[map.Name] = 0 -- Just use numbers.
	end
	
	local playersVoted = {}
	
	local voteTracker = function(player, choice) -- Is `choice` a string?
		if not (typeof(choice) == "string") then
			return -- Block players whose inputs are invalid. Sanity checking is very important.
		end
		
		if not table.find(playersVoted, player) then
			return -- Block players who have already voted.
		end
		
		local mapSelected = votes[choice]
		
		if mapSelected then
			table.insert(playersVoted, player)
			mapSelected += 1
		end
	end
	
	local voteConnection = voteRemoteEvent.OnServerEvent:Connect(voteTracker)

	for i = 10, 1 -1 do
		info.Messages.Value = "Map voting ".. i 
		task.wait(1)
	end
	
	voteConnection:Disconnect() -- Stop collecting votes.

	local winVote = nil
	local winScore = 0

	for name, map in pairs(votes) do
		if map > winScore then
			winScore = #map
			winVote = name
		end
	end
	
	return winVote
end

Also, check if the output is still nil, then restart the voting process until a winner is chosen (or select a random map instead).

Didnt help error is still there

17:20:50.541 Stack Begin - Studio
17:20:50.542 Script ‘ServerScriptService.Main.Round’, Line 15 - function LoadMap - Studio - Round:15
17:20:50.542 Script ‘ServerScriptService.Main’, Line 10 - Studio - Main:10
17:20:50.542 Stack End - Studio

The error is pretty self explanatory, but let me explain it anyway.
Your code is trying to access the .Map property of the Round module script, but there is no such property defined in that module script.
You can either create a Map property in Round or remove all references to it.