Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Voting count gui script and display isn't working?

When a player presses a button an event will fire, then a script will read when that event fires and change a value (the vote count), then send an event back to a local script to change the display count on a text button. My count value is called value so that is why I use Value.Value (ik it's weird)

Local script

Value = script.Parent.Value

script.Parent.Text = Value.Value

game.ReplicatedStorage.Vote1.OnClientEvent:Connect(function()
	script.Parent.Text = Value.Value
end)



Normal script

game.ReplicatedStorage.Vote.OnServerEvent:Connect(function()
	game.StarterGui.ScreenGui.Votes.Value.Value = game.StarterGui.ScreenGui.Votes.Value.Value + 1
	game.ReplicatedStorage.Vote1:FireClient()
end)

1 answer

✓ Accepted answer

There are two errors. At line 2 of the 2nd script, you should change the value of every Player's gui, and not in the Starter gui. To do that, we need to get the player. How? Like this:

game.ReplicatedStorage.Vote.OnServerEvent:Connect(function(player)
        for i, v in pairs (game.Players:GetChildren()) do
                v.PlayerGui.Votes.Value.Value = v.PlayerGui.Votes.Value.Value +1
        end
        game.ReplicatedStorage.Vote1:FireAllClients()
end)

Also, you have to change the GUI text of every players. So I added a :FireAllClients() instead of :FireClient().

If you really just wanna use :FireClient(), you have to include the player between the brackets. Like this

FireClient(player)

Also, in the local script, you made a variable at line 3 that gets the value. The problem is that the Value never changes, because you just get it once. Instead, put line 3 inside the function OnServerEvent so it upgrades every time. Make sure to also put line 1 into the function, because line 3 uses line 1's variable, so line 1's variable needs to also change.

Hope this helped!

3 comments

0

That helped, but I probably should have described it better, the value was changing but the text label wasn't, so the first script worked but there was something wrong with the local because the label wasn't updating

0

oh

0

Ok I added something. Did it work?

This discussion is preserved as it was. New answers, comments, and votes are closed.