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

Why does my Text Button not work properly?

Asked by 3 years ago

sooooooooo I haven't done lua in a year so I'm a bit rusty and I'm curious why this doesn't work

01local button = script.Parent
02 
03local function onButtonActivated()
04    if script.Parent.Text = "Back" then
05        script.Parent.text = "Credits"
06 
07    else
08 
09        script.Parent.Text = "Back"
10    end
11end
12 
13button.Activated:Connect(onButtonActivated)

1 answer

Log in to vote
1
Answered by 3 years ago

use this:

1local button = script.Parent
2 
3button.MouseButton1Click:Connect(function()
4    if script.Parent.Text == "Back" then
5        script.Parent.Text = "Credits"
6        else script.Parent.Text = "Back"
7    end
8end)
0
Ah yes thank you! It's starting to come back to me User#39520 0 — 3y
0
wait but why MouseButton1Click? isnt it better to use Activated because Activated can support mobile and pc? PaleNoobs 37 — 3y
Ad

Answer this question