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)
Make server change text label, not Player locally.
I mean you to forget FiringAllClients, you should just fire Server From Client Whenever Player Votes. Then Vote should be displayed by server in server script