Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

is it possible to add plus 1 to a value in gui button?

Asked by 3 years ago

I am currently making a map voting system, and i cant figure this out. Will i be able to add plus one to a int value in replicated storage, by pressing a gui button in a local script? Sense its in a local script im not sure if it will only show plus one for the player,or for everyone. How would i go about doing this?

1 answer

Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
3 years ago
Edited 3 years ago

I do recommend you read everything in that link, but to make it easier for you, the only thing you need to know in regards to your question (using pseudo code) is this:

In a local script:

local RE = game.ReplicatedStorage.RemoteEvent

RE.OnClientEvent:Connect(function(specified_gui,value_to_add)
    specified_gui += value_to_add
end)

GUI_Button_Pressed:Connect(function()
    RE:FireServer()
end)

In a server script:

local RE = game.ReplicatedStorage.RemoteEvent

RE.OnServerEvent:Connect(function(Player)
    RE:FireAllClients(gui,1)
end)

Basically the idea is that when your player presses the map vote button, it fires through the remote to the server, and then the server fires all clients to update their guis of the vote in progress. Just make sure you have the remote event, and rewrite this using your variables and events, and it should work.

I would love to give you more than this, but you didn't make an attempt of your own, so this is as much as I can give you. And if this helps answer your question, then mark it as the accepted answer, and if not, then I'd be happy to answer any further questions you may have about this in the comments below.

0
Thanks! I don't know what i was thinking. I should of thought about Remote events. Carlowskey 20 — 3y
Ad

Answer this question