Help with map voting system

hey, I’ve been trying to make a map voting system and select 3 random maps to vote. I have a problem with sending a table from server to client through remoteevents, when I try looping a table in serverscript, it works fine. However, when I try looping a table in client script, it won’t print out anything. here’s the code:

Server (ModuleScript):

	local maps = allMaps:GetChildren()
	votes = {}
	mapFolder = {}
	
	repeat task.wait()
		local random = math.random(#maps)
		for i , v in pairs(maps) do
			if random == i then
				if not table.find(mapFolder, v) then
					table.insert(mapFolder, v)
				end
			end
		end
	until #mapFolder == 3
	for i, v in pairs(mapFolder) do print(v) end -- this prints the selected map
	events:WaitForChild("UpdateMapsClient"):FireAllClients(mapFolder)

Client:

	events:WaitForChild("UpdateMapsClient").OnClientEvent:Connect(function(mapFolder)
		local buttons = {}
		buttons = {}
		
		for i, v in pairs(frame:GetChildren()) do
			if v:IsA("ImageButton") then
				table.insert(buttons, v)
			end
		end
		for i, v in pairs(mapFolder) do -- this doesn't
			print(i, v)
		end
	end)

help will be appreciated

Oof, you hurt your brain and i think the only reason is because you forgot remote events need/have a player parameter

The remote event he used is :FireAllClients() which means it fires to every player.

2 Likes

I do have remote event, and I don’t think :FireAllCients() needs a player parameter?

You guys are correct, I was in a rush and didn’t see that

What does the allMaps variable point to? If it works in the server but not the client my only assumption is that you’re trying to pass instances that the client cannot see (Such as instances in ServerStorage)

1 Like

You’re right, I placed the maps inside ServerStorage. I didn’t think of that. Thanks a lot!

1 Like