Weird problem with server values🪲

Hello developers,

I have ran into another problem. (yay)

Now my problem happened when I was trying to make a voting system and I was working on the client. I’ve tested and I think I found what the error is, but not how to solve it. When counting votes I add them to a value, and then when the round is over I reset the value to 0 but when I check the value on the Server it keeps adding AFTER I reset it. But the weird part is when I vote for a new map the value just moves.

↓ Watch the video to understand what I mean


You see in the video that the value doesn’t change, and just keeps adding.

Code

:warning: No script error is in the output

This code is a part of a while true do loop. Now some of you may be asking is this a server script? Yes, the script I am clearing it on is a server script.

OfficeVote.Value = 0 -- Suppost to clear the value
PodcastVote.Value = 0
CrossroadsVote.Value = 0
print("Office Votes: "..OfficeVote.Value.." Podcast Votes: "..PodcastVote.Value.." Crossroads Votes: "..CrossroadsVote.Value)
Later down the code…

Now in this part, I add the votes.

VoteEvent.OnServerEvent:Connect(function(Player, MapVote)
			if CanVote == true then
				if MapVote == "Office" then
					OfficeVote.Value += 1
				elseif MapVote == "Podcast" then
					PodcastVote.Value += 1
				elseif MapVote == "Crossroads" then
					CrossroadsVote.Value += 1
				end
			end
			ReplicatedStorage.Main.Voting.VotedEvent:FireAllClients(MapVote, OfficeVote, PodcastVote, CrossroadsVote, Player)
		end)
1 Like

I’m not exactly sure why this is behaving like this, without more code for better understanding, but I’d probably opt for Attributes rather than Value objects, and if a client needs the votes value, send it via a remote rather than relying on replicated objects since it would be more reliable.

Ideally, there would be no issue, but I’m still not entirely certain if this is a fault somewhere along your code or if it’s a quirky bug that Roblox engineers have yet to discover.

Also, rather than using a while loop, you may opt for a functional approach.
When a round ends, you call a reset function, which resets the values.
Then, after that function resets the values, you set CanVote to true and allow Players to vote.

Let me know if you need anything else, but that’s my take.

1 Like

Hey, thanks for the reply. I’m wondering why you would rather do Attributes then Values objects?

getattribute cant be seen by the explorer. but value objects do. value objects can flood your explorer then you get exhausted by scrolling and seeing bunch of gray stuff.

1 Like

I understand that if an exploiter changes a value on the client side it will not affect the server

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.