Help with changing player's value via remote event

I’ve been making a political simulator, and right now I’m trying to make a speaker of the parliament election process. The voting UI pops up every new term on day 1, and players should click on the player they want to vote for. The player with most votes wins (the most votes works and doesn’t need fixing).

My local script:

btn.MouseButton1Up:Connect(function()
	
	for _,v in pairs(game.Players:GetPlayers()) do
		if username.Text == v.Name then
			local player = username.Text
			ve:FireServer(player)
			script.Parent.Parent.Parent.Visible = false
		end
	end
	
	
	
	while true do
		task.wait()
		if workspace.GlobalStats.Hour.Value == 9 then
			script.Parent.Parent.Parent.Parent.Main.Visible = false
		else
			script.Parent.Parent.Parent.Parent.Main.Visible = false
			break
		end
	end
	
end)

My server script:

e.OnServerEvent:Connect(function(plr, player)
	
	if game.Players:FindFirstChild(player) then
		game.Players:FindFirstChild(player).leaderstats.VotesSpeaker.Value += 1
		print(game.Players:FindFirstChild(player).leaderstats.VotesSpeaker.Value)
	end
	
end)

The print prints 1, but when I look at the value on the server side, it is 0… or when I print the value in another script, it also says 0.

What is wrong with this script? I have NO idea what I’m doing wrong. If it helps, voting button is a clone for each parliamentarian.

2 Likes

i do not recommend making a political game on Roblox because this may get you in trouble

1 Like

why you have to player value one called player and the other one called plr ? just do not pass any thing in the local script and the remote event will give the player who fired the event already

1 Like

The first variable of an event is the player who fired it, and the other is an optional variable you send over.

I don’t want the Value of the player who fired the event to be changed, but rather the player who has been voted for, as previously stated.

I understand that politics is allowed as long as it does not reference real life. (Like politicians or real life political parties)

1 Like

I fixed it. Turns out I had a loop in some random script that kept resetting it back to 0.

1 Like

glad to hear that it works now

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