local RemoteFunction = game.ReplicatedStorage.RemoteFunction
local votes = {}
for i,plr in pairs(game.Players:GetChildren()) do
spawn(function() table.insert(votes,RemoteFunction:InvokeClient(plr)) end)
end
If the remote function doesn’t return anything, could this cause a memory leak? I can have the client return an empty string before the main script starts counting the votes and count the empty string as an invalid vote. But I don’t know what I can do about exploiters, they can just delete the local script and nothing is returned to the server. Doesn’t this fact make remote functions ever unreliable?
Yeah, never use RemoteFunction:InvokeClient. You can instead use a two-way remote event.
I am not sure how or where you store which player voted for what so that the server invokes the client, so if you can explain how you do that I can help you further.
Have the client send their vote info through a RemoteEvent and store it on the server. When the timer runs out, use the data you currently have (players that don’t vote in time get skipped).
I thought it would be easier to use a remote function in this situation, so I switched from a two-sided event to a remote function. But now I understand that remote functions are not very good for this situation…