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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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

0
And to change the text of a button do this: script.Parent.Text = "Text here" Destroyer1234x 52 — 4y
Ad

Answer this question