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

How to make a GUI Button that can change a value?

In my game, I have a screen GUI with a frame, TextButton.

How would I make it that when the player presses the screen GUI, it changes a value?

Thank you!

3 answers

This will need to be in a script inside of the button. You can modify the script.Parent path as needed if your script is elsewhere.

script.Parent.MouseButton1Click:connect(function()
	game.Workspace.ExampleValue.Value = 1 -- replace with needed path
end)

Scripting Helpers is not a request site

But I can give you some help

local textButton = -- TextButton location here.   Or just script.Parent if the script is inside of the button
textButton.MouseButton1Down:connect(function() -- Connect the function
	--Here you just have the value change, example:
game.Workspace.NumberOfClicks = 19
end

Of course you would add a lot more lines to fit your liking, but you get the point.

script.Parent.MouseButton1Click:connect(function()
    game.Workspace.TheValue.Value = 0 -- Change "0" to what you want the value to equal
end)

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