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

How do I change the text of a text button through a local script?

I'm trying to make it so that when the player clicks on the button "Mug" it gives them a mug and changes the text to blank.~~~~~~~~~~~~~~~~~

local txt = script.Parent.Text
local mug = game.ReplicatedStorage.Mug
local button = script.Parent

button.MouseButton1Click:Connect(function()
	mug.Parent = game.Players.LocalPlayer.Backpack
	txt = "ToolName"
end)

1 answer

✓ Accepted answer

Are you trying to give the mug to the player via that local script? That won't work. You would need use Remote Events to fire an event to a Server Script so they can handle the rest. You can change the text of the button on the local script though.

You can read more about Remote Events here: https://developer.roblox.com/en-us/api-reference/class/RemoteEvent

1 comment

0

And to change the text of a button do this: script.Parent.Text = "Text here"

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