Hello, I'm trying to make a map vote system where multiple people can vote at the same time that limits each player to one vote and chooses the map with the most votes (the map choosing system is somewhere else in the script).
The problem is that; the textlabel doesnt update when there is more than one player trying to vote on the same thing or rather it does update but it doesnt update for other players until they vote on something else
I thought FireAllClients() handles this? Why isn't the textlabel updating for everyone?
I put comments explaining everything that needs to be explained in the scripts below (if the comments makes everything look confusing please tell me and ill remove them)
Local script
voteFrame.MapImage1.MouseButton1Click:Connect(function()
--when player clicks on a imagebutton to vote
if playerVote.Value == map1.Name then --if player is trying to vote for the same thing
print("plr already voted for this")
elseif playerVote.Value ~= map1.Name and playerVote.Value == map2.Name then
--if player's previous vote was map2 and not map1
playerVote.Value = map1.Name --change their vote to map1
--votenum1 is the total votes for map1 (is displayed on the textlabel)
--votenum2 is the total votes for map2 (is displayed on the textlabel)
--voteframe.mapimage1.mapname is the location of the textlabel for map1 (map2 is mapimage2.mapname)
changeVoteEvent:FireServer("VoteNum1", "VoteNum2", voteFrame.MapImage1.MapName, voteFrame.MapImage2.MapName, map1.Name, map2.Name)
elseif playerVote.Value ~= map1.Name and playerVote.Value == map3.Name then
--if player's previous vote was map3 and not map1
playerVote.Value = map1.Name --change their vote to map1
--votenum3 is the total votes for map3
--mapimage3.mapname is the location of the textlabel
changeVoteEvent:FireServer("VoteNum1", "VoteNum3", voteFrame.MapImage1.MapName, voteFrame.MapImage3.MapName, map1.Name, map3.Name)
else
playerVote.Value = map1.Name
--if the player didnt have a previous vote, change it to map1
changeSingleVoteEvent:FireServer("VoteNum1", voteFrame.MapImage1.MapName, map1.Name)
end
end)
Server script that handles the value changes and the text label changes
local function mapVoteEventFired(plr, target1, target2, text1, text2, map1, map2, otherValue, otherText, otherMap)
--target1 is the value thats being added to
--target2 is the value thats being subtracted from
local target1 = script:FindFirstChild(target1) --finds the first value
local target2 = script:FindFirstChild(target2) --finds the second value
local otherValue = script:FindFirstChild(otherValue) --finds the third value (just to keep things updated)
target1.Value = target1.Value + 1
target2.Value = target2.Value - 1
text1.Text = map1..": "..target1.Value
text2.Text = map2..": "..target2.Value
otherText.Text = otherMap..": "..otherValue.Value
end
local function mapSingleVoteEventFired(plr, target, text, map)
--does the same thing as the function above except it just changes 1 variable (if the player has no previous vote)
local target = script:FindFirstChild(target)
target.Value = target.Value + 1
text.Text = map..": "..target.Value
end
changeSingleVoteEvent.OnServerEvent:Connect(mapSingleVoteEventFired)
changeVoteEvent.OnServerEvent:Connect(mapVoteEventFired)

20 comments
still doesnt update for everyone
Sorry, is it in PlayerGui?
I know the issue
yea
I just want to know it better, it's not that simple
the parent of the values are in the server script (which is in serverscriptservice), and the local script is in the gui
I updated my scripts to show how my script looks now, got rid of FireAllClients and updated text label through the server, still doesnt work
Where is scripts located?
as i said previously, the server script is located in serverscriptservice, and the local script is in a screengui under startergui
you make sure that text label is active and Gui is enabled and things like that? cause everytime I thought I found mistake it turned out not to be mistake
you deleted some code and changed serverscript
yea, the code I deleted was the textlabel being changed on client, textlabel is now changed through server
also textlabel is active and gui is enabled, etc
still problem?
still problem?
yea it doesnt work still
can you elaborate at which exact point does it change and when it doesn't
what do you mean by "which exact point does it change and when it doesnt"? are u asking where the vote value changes and where textlabel is updated? if so, its in server script. local script exists to check if player clicked on the imagebutton and to check their previous vote and change it to their new vote
do you have a discord we can msg over? it'd be easier that way imo
yes I have discord, but if you are in server