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

How do I make it that if a tButton is clicked from a GUI, it changes a value in the workspace?

Asked by 4 years ago
Edited 4 years ago

So, I am making a minigame place, and it has a GUI for the players to click on and pay Robux to pick the next minigame. It works fine, but the only problem is that there is a string value in the workspace. I want to make it so when the button is pressed, it changes it to the value that it's set to.

If i insert a local script into the textbutton and type this code...

script.Parent.MouseButton1Click:Connect(function()
  workspace.Value.Value = "Obby"
end)

..it will only show up to the client. It will not change for the server.

How do i make it so it does change for the server?

Please let me know.

1 answer

Log in to vote
0
Answered by
zomspi 541 Moderation Voter
4 years ago

You need to use a remote event, put a remote vent inside of replicated storage, change remote event to the name of your remote event.

Local script inside the button gui

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)


Server script inside workspace or serverscriptservice

local value = game.Workspace.NumberValue.Value -- Change this to the path of your value
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
value = value + 1 -- Change this number to how much you want to value to increase each time the button is clicked / pressed
end)

If you need any other help please feel free to ask!

0
Also you can change it to a string just remove the plus zomspi 541 — 4y
Ad

Answer this question