Module Script Activated Twice?

  1. What do you want to achieve?
    I want to make a tower defense game but somehow the map and the enemies that spawned in is somehow doubled as the amount of players in that server.

  2. What is the issue?
    I think the issue that is The Module Scripts is somehow accouring the same amount as the players that are in the server.

  3. What solutions have you tried so far?
    I found a same problem that I have in the devforum, they said its because the Module Scripts is behaving like a Client and a Server Scripts. I don’t know how to fix it

Here Is the Module Scripts thats in my game:

The Round Module Script (The one that choose when the enemies and what maps that has been choosen)

function round.LoadMap()
	local votedMap = round.ToggleVoting()
	local mapRound = serverStorage.Maps:FindFirstChild(votedMap)
	
	if not mapRound then
		mapRound = serverStorage.Maps.TestPlace
	end
	
	local newMap = mapRound:Clone()
	newMap.Parent = workspace.Map
	
	newMap.Base.Humanoid.HealthChanged:Connect(function()
		if newMap.Base.Humanoid.Health <= 0 then
			info.GameRunning.Value = false
			for i, mob in ipairs(workspace.Mobs:GetChildren()) do
				mob:Destroy()
			end

			info.Massage.Value = "DEFEATED"
		end
	end)
	
	local skyFolder = newMap:FindFirstChild("SkyFolder")
	if skyFolder then
		for i, v in pairs(skyFolder:GetChildren()) do
			v.Parent = game.Lighting
		end
	else
		warn("Sky Folder did not found in this map")
	end
	
	return newMap 
end

function round.ToggleVoting()
	local mapsFolder = serverStorage.Maps:GetChildren()
	
	maps = {}
	votes = {}
	
	repeat
		local map = mapsFolder[math.random(1, #mapsFolder)]
		if not table.find(maps, map.Name) then
			table.insert(maps, map.Name)
		end
	until #maps == 3

	for i, map in ipairs(maps) do
		votes[map] = {}
	end

	events.SelectingMaps:FireAllClients(maps)
	info.Voting.Value = true
	print(#votes)
	
	for i = 15, 1, -1 do
		info.Massage.Value = "Map Voting In Progress - "..i
		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
	
	if not winVote then
		local n = math.random(1, #maps)
		winVote = maps[n]
	end
	
	info.Voting.Value = false
	
	print(winVote)
	
	return winVote
end

function round.ProcessVote(player, vote)
	
	for i, mapVotes in pairs(votes) do
		local oldVote = table.find(mapVotes, player.UserId)
		if oldVote then
			table.remove(mapVotes, oldVote)
			break
		end
	end
	
	table.insert(votes[vote], player.UserId)
	
	print(vote)
	events:WaitForChild("UpdateVoteCount"):FireAllClients(votes)
end
events:WaitForChild("CastMapVote").OnServerEvent:Connect(round.ProcessVote)

function round.GetWave(wave, map)
	if wave == 1 then
		mobModule.Spawns("Normal Bot", 5, map)
	elseif wave < 3 then
		mobModule.Spawns("Normal Bot", (4 * wave), map)
	elseif wave == 3 then
		for i = 1, 3 do
			mobModule.Spawns("Normal Bot", 2, map)
			mobModule.Spawns("Speed Bot", 1, map)
		end
		mobModule.Spawns("Normal Bot", 3, map)
	elseif wave == 4 then
		for i = 1, 5 do
			mobModule.Spawns("Normal Bot", 2, map)
			mobModule.Spawns("Speed Bot", 1, map)
		end
	elseif wave == 5 then
		mobModule.Spawns("Strong Bot", wave, map)
	elseif wave == 6 then
		for i = 1, wave - 5 do
			mobModule.Spawns("Normal Bot", 4, map)
			mobModule.Spawns("Speed Bot", 3, map)
			mobModule.Spawns("Strong Bot", 2, map)
		end
	elseif wave == 7 then
		for i = 1, 3 do
			mobModule.Spawns("Normal Bot", 3, map)
			mobModule.Spawns("Speed Bot", 2, map)
			mobModule.Spawns("Strong Bot", 2, map)
		end
		mobModule.Spawns("Normal Boss", 1, map)
	elseif wave < 10 then
		for i = 1, wave - 7 do
			mobModule.Spawns("Normal Bot", 5, map)
			mobModule.Spawns("Speed Bot", 5, map)
			mobModule.Spawns("Strong Bot", 4, map)
		end
		mobModule.Spawns("Normal Boss", wave - 6, map)
	elseif wave < 13 then
		for i = 1, wave - 7 do
			mobModule.Spawns("Normal Bot", 5, map)
			mobModule.Spawns("Speed Bot", 5, map)
			mobModule.Spawns("Strong Bot", 4, map)
		end
		mobModule.Spawns("Strong Boss", wave - 9, map)
	elseif wave <= 15 then
		for i = 1, wave - 7 do
			mobModule.Spawns("Normal Bot", 5, map)
			mobModule.Spawns("Speed Bot", 5, map)
			mobModule.Spawns("Strong Bot", 4, map)
		end
		mobModule.Spawns("Strong Boss", wave - 10, map)
		mobModule.Spawns("Speed Boss", wave - 12, map)
	end
end

The Enemies Module Scripts (The one that spawns the enemies)

function mob.Spawns(name, quantity, map)
	local mobExists = serverStorage.Mob:FindFirstChild(name)
	workspace.GameInfo.Enemies.Value += quantity

	if mobExists then
		for i = 1, quantity, 1 do
			wait(0.75)
			local newMob = mobExists:clone()
			newMob.Parent = workspace.Mobs
			newMob.HumanoidRootPart.CFrame = map.Start.CFrame
			newMob.HumanoidRootPart:SetNetworkOwner(nil)
			
			local movingTo = Instance.new("IntValue")
			movingTo.Name = "MovingTo"
			movingTo.Parent = newMob
			
			for i, object in ipairs(newMob:GetDescendants()) do
				if object:IsA("BasePart") then
					object.CollisionGroup = "Mobs"
				end
			end	
			
			newMob.Humanoid.Died:Connect(function()
				wait(1)
				newMob:Destroy()
				workspace.GameInfo.Enemies.Value -= 1
			end)
			
			coroutine.wrap(mob.Move)(newMob, map)
		end	
	else
		warn("Requested mob doesn't exists: ", name)
	end
end

Here is some Screenshots and Recordings ;

What’s the script that fire’s the functions. You can’t just hand us a Base and have us guess how you’re firing them.

Private message if you don’t want it publicly accessible.