Categories > Coding > Lua >

Change TextLabel's Text when its clicked to a button

SupremeDoritos

EX SCRIPTER FROM 2022

Posts: 39

Threads: 16

Joined: May, 2022

Reputation: 2

Posted

local textm = "I eat some Doritos" -- Text that you want to show
local textbox = script.Parent.Parent.TextBox -- Textbox script

script.Parent.MouseButton1Click:Connect(function()
textbox.Text = textm
end)

 

Make a script and put that

 

  • 0

https://cdn.discordapp.com/attachments/1041233366428696607/1120019992700801134/Ryzen.png

 

Posts: 93

Threads: 2

Joined: Apr, 2023

Reputation: 6

Replied

use .Activated instead of MouseButton1Click

Comments

EggEnthusiast 5 Reputation

Commented

.MouseButton1Down is also a good alternative.

  • 0

  • 0

"your code looks like a decompiled roblox script", - Whoman

Posts: 1

Threads: 0

Joined: Jun, 2023

Reputation: 0

Replied

Your script seems to be correct, but you need to make sure that the button and the textbox are in the same frame or screen GUI. You also need to name the button and the textbox according to your script. 

 

splatoon 3

Comments

Aetheron 5 Reputation

Commented

His script is though very generic and gives a general understanding of how a button works.

You just edit the variable to the path of your TextLabel or Textbox to modify the text,

 

I did not understand your point in this reply.

  • 0

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )