Voting System not working

Hi There!
I have a voting system, but it’s suddenly stopped working!
The player can choose their vote, but then they can’t change it!
Server script:

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Events = ReplicatedStorage:WaitForChild('Events')
local Votes = ReplicatedStorage:WaitForChild('Votes')
local MPS = game:GetService('MarketplaceService')

Events.AddVote.OnServerInvoke = function(...)
	local Args = {...}
	local Player = Args[1]
	local MapNumber = Args[2]
	
	
	if Player and MapNumber then
		local VoteToAdd = Votes:FindFirstChild('Map'..MapNumber)
		if VoteToAdd ~= nil then
			if not MPS:UserOwnsGamePassAsync(Player.UserId,11254132) then
				VoteToAdd.Value += 1
			else
				VoteToAdd.Value += 2
			end
			if Player.MapVoted.Value ~= 0 then
				local VoteToRemove = Votes:FindFirstChild('Map'..Player.MapVoted.Value)
				if VoteToRemove ~= nil then
					if not MPS:UserOwnsGamePassAsync(Player.UserId,11254132) then
						VoteToAdd.Value -= 1
					else
						VoteToAdd.Value -= 2
					end
				else
					return false
				end
			end
			Player.MapVoted.Value = MapNumber
			return true
		else
			return false
		end
	else
		return false
	end
end

game.ReplicatedStorage.Votes.Map1:GetPropertyChangedSignal('Value'):Connect(function()
	workspace.NewLobby:WaitForChild('MapVoting',math.huge).Vote.Office.Vote.Text = 'Votes: '..game.ReplicatedStorage.Votes.Map1.Value
end)

game.ReplicatedStorage.Votes.Map2:GetPropertyChangedSignal('Value'):Connect(function()
	workspace.NewLobby:WaitForChild('MapVoting',math.huge).Vote.Park.Vote.Text = 'Votes: '..game.ReplicatedStorage.Votes.Map2.Value
end)

game.ReplicatedStorage.Votes.Map3:GetPropertyChangedSignal('Value'):Connect(function()
	workspace.NewLobby:WaitForChild('MapVoting',math.huge).Vote.Supermarket.Vote.Text = 'Votes: '..game.ReplicatedStorage.Votes.Map3.Value
end)

game.ReplicatedStorage.Events.ResetMapVoting.Event:Connect(function()
	game.ReplicatedStorage.Events.ResetMapVotingClient:FireAllClients()
	for Index, Player in pairs(game.Players:GetPlayers()) do
		spawn(function()
			Player.MapVoted.Value = 0
		end)
	end
	for Index, Vote in pairs(game.ReplicatedStorage.Votes:GetChildren()) do
		Vote.Value = 0
	end
end)

Local Script:

local Player = game.Players.LocalPlayer
local CanVote = false
local HasVotedFor
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Events = ReplicatedStorage:WaitForChild('Events')

game.ReplicatedStorage.Events.ResetMapVotingClient.OnClientEvent:Connect(function()
	CanVote = true
	HasVotedFor = nil
end)

Events.DisableVoting.OnClientEvent:Connect(function()
	CanVote = false
end)

workspace.NewLobby:WaitForChild('MapVoting',math.huge).Vote.Office.MouseButton1Click:Connect(function()
	if HasVotedFor ~= 1 then
		if CanVote == true then
			HasVotedFor = 1
			local AddVote = Events.AddVote:InvokeServer(1)
			if AddVote then
				print('successful!')
				workspace.Success:Play()
			else
				workspace.Error:Play()
			end
		end
	end
end)

workspace.NewLobby:WaitForChild('MapVoting',math.huge).Vote.Park.MouseButton1Click:Connect(function()
	if HasVotedFor ~= 2 then
		if CanVote == true then
			HasVotedFor = 2
			local AddVote = Events.AddVote:InvokeServer(2)
			if AddVote then
				workspace.Success:Play()
			else
				workspace.Error:Play()
			end
		end
	end
end)

workspace.NewLobby:WaitForChild('MapVoting',math.huge).Vote.Supermarket.MouseButton1Click:Connect(function()
	if HasVotedFor ~= 3 then
		if CanVote == true then
			HasVotedFor = 3
			local AddVote = Events.AddVote:InvokeServer(3)
			if AddVote then
				workspace.Success:Play()
			else
				workspace.Error:Play()
			end
		end
	end
end)

Interestingly enough, the success sound plays, but the votes don’t change!
I get no errors, thanks for any help!

I’m not getting any errors AT ALL!
If I haven’t made it clear:

The vote gets added when the player puts their vote, but when they click another map to vote(change their vote), it doesn’t work. I’m pretty sure it’s an issue with the server script because the success sound plays.

1 Like

Hi, suggest uploading a model with the voting system? This way I can try it out and see what’s the problem.

Also, your waiting for math.huge? Math.huge is an infinite number, not an object.

I’ve explained what the problem is on my post, so I suggest READING it.

Ok hear me out this is a very old topic.

If he wants a model, why dont you give it? He can easily help you, and I am assuming he read it and he wants a model to further see whats wrong. If you really want help, always supply people with as much info!