Hello,
I have decided to make a map voting system. However the issue is that I have two remote events but only one of them is working correctly. updateTime is as the name suggests - used for updating the countdown on the client, and the updateMaps (which I have an issue with) is supposed to update the maps gui on the client (currently it is only supposed to print).
-- Server script
local mapsFolder = game.ServerStorage.Maps:GetChildren()
local currentMap = game.Workspace.CurrentMap
local rp = game.ReplicatedStorage
local gui = game.StarterGui.MapVoting
function getMapsPool () -- NOT IMPORTANT
local mapsFolderCopy = mapsFolder
local randomizedMaps = {}
local mapsPool = {}
repeat
local x = math.random(1, #mapsFolder)
if mapsFolderCopy[x] ~= nil then
table.insert(randomizedMaps, mapsFolderCopy[x])
mapsFolderCopy[x] = nil
end
until #randomizedMaps == 3
for k, v in pairs(randomizedMaps) do
mapsPool[v.Name] = 0
end
return mapsPool
end
function voting ()
currentMap:ClearAllChildren()
rp.MapVoting.updateMaps:FireAllClients(getMapsPool())
spawn(function()
for i = 30, 0, -1 do
wait(1)
rp.MapVoting.updateTime:FireAllClients(i)
end
end)
end
voting()
-- Client script
local rs = game.ReplicatedStorage
local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("MapVoting")
rs.MapVoting.updateMaps.OnClientEvent:Connect(function (maps)
print(maps) --nothing
print("does it even work") --also nothing
end)
rs.MapVoting.updateTime.OnClientEvent:Connect(function (i)
gui.Countdown.Text = i
end) -- this function works correctly
I really wish to know what is causing this issue and how to fix it. I have tried changing the assigning getMapsPool() as a value of a variable and then passing that variable into the event fire but that didn’t seem to work.