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.