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

local button = script.Parent

local function onButtonActivated()
    if script.Parent.Text = "Back" then
        script.Parent.text = "Credits"

    else

        script.Parent.Text = "Back"
    end
end

button.Activated:Connect(onButtonActivated)

1 answer

Log in to vote
1
Answered by 3 years ago

use this:

local button = script.Parent

button.MouseButton1Click:Connect(function()
    if script.Parent.Text == "Back" then
        script.Parent.Text = "Credits"
        else script.Parent.Text = "Back"
    end 
end)
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