What do you want to achieve? I am needing help creating a player voting gui thats shows all players in the server and the name on there name gui inside there character. And gives a reward to the most voted player
What is the issue? I have been looking for support of starting and cant find any help on how to display names or tallying votes
I am looking to create something similar to royale high. My game depends on players characters so I need it to use players names in there character
You could probably store all votes in a table on the server using remote events. Ex.
-- LocalScript:
local remoteEvent = game:GetService('ReplicatedStorage').RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
local vote = game:GetService('Players'):FindFirstChild('ramen_rqman') -- let's say I'm voting for you
remoteEvent:FireServer(vote)
end)
-- ServerScript:
local votes = {}
local voteTallied = {}
local remoteEvent = game:GetService('ReplicatedStorage').RemoteEvent
local function prepareVotes
for i,v in pairs(game.Players:GetPlayers()) do
votesTallied['v.Name'] = 0
end
end
remoteEvent.OnServerEvent:Connect(function(player, vote)
if votes[player.Name] then
votesTallied[votes[player.Name]] -= 1 -- subtract one from the old votee because they're changing their vote
end
votes[player.Name] = vote --[[ Would look like:
local votes = {
['7z99'] = ramen_rqman -- another thing to keep in mind is that you're sending the player instance, not the player's name.
} ]]
votesTallied[vote.Name] += 1 -- add 1 to the new votee's tally
end)
Do have to warn you that the script posted above is an extremely high exploitation (Exploiters can fire any remote they want passing any argument they want) not only checking if the player is an actual player letting them just submit any name they want but also letting them vote as many things as possible to whoever. I thought about it for a bit but cant think of anything besides making sure what is submitted is a player.
They have to pass an argument that exists on the server and is a child of Players. It’s also the reason you subtract one from their old vote. They aren’t able to modify server data so it’s relatively safe.
Ahhhhh. i see it now. Thats why i couldnt find a fix lol its currently 3 am and im dont wanna fall asleep. But yeah 100% forgot that client to server passes the player firing the event