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

Why does my Text Button not work properly?

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

✓ Accepted answer

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)

2 comments

0

Ah yes thank you! It's starting to come back to me

0

wait but why MouseButton1Click? isnt it better to use Activated because Activated can support mobile and pc?

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