Changing Text Using A Script Isn't Working

I have a local script in a textlabel. And I have a different script that sets the textlabel to visible. I want the text to change but it’s not working.

local Label = script.Parent

while Label.Visible == true do
	Label.Text = "πŸ’¬ Typing πŸ’¬"
	wait(0.75)
	Label.Text = "πŸ’¬ .Typing. πŸ’¬"
	wait(0.75)
	Label.Text = "πŸ’¬ ..Typing.. πŸ’¬"
	wait(0.75)
	Label.Text = "πŸ’¬ ...Typing... πŸ’¬"
	wait(0.75)
end

Use GetPropertyChangedSignal to commense the loop anytime the property is changed to true

local Label = script.Parent

Label:GetPropertyChangedSignal("Visible"):Connect(function()
	while Label.Visible do
		Label.Text = "πŸ’¬ Typing πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ .Typing. πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ ..Typing.. πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ ...Typing... πŸ’¬"
		wait(0.75)
	end
end)

Also you may need to figure out how to reduce the repetition, but for now, this should fix it

How would I stop the loop once it becomes not visible?

It’ll do so automatically as the loop stops if the property is not set to true

It isn’t stopping automatically, when it becomes visible then invisible, the loop is still running. So it has two loops when it becomes visible again and then three loops going when it becomes visible again at the same time and so on.

Try this?

local Label = script.Parent

local loop = false

Label:GetPropertyChangedSignal("Visible"):Connect(function()
	loop = Label.Visible
	if not loop then
		return
	end
	while loop do
		Label.Text = "πŸ’¬ Typing πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ .Typing. πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ ..Typing.. πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ ...Typing... πŸ’¬"
		wait(0.75)
	end
end)

Not sure if the extra variable is needed

It still doesn’t work. :face_with_raised_eyebrow:

Try this

local Label = script.Parent

local loop = false

Label:GetPropertyChangedSignal("Visible"):Connect(function()
	loop = Label.Visible
	if not loop then
		return
	end
	while loop do
if not loop then break end
		Label.Text = "πŸ’¬ Typing πŸ’¬"
		wait(0.75)
if not loop then break end
		Label.Text = "πŸ’¬ .Typing. πŸ’¬"
		wait(0.75)
if not loop then break end
		Label.Text = "πŸ’¬ ..Typing.. πŸ’¬"
		wait(0.75)
if not loop then break end
		Label.Text = "πŸ’¬ ...Typing... πŸ’¬"
		wait(0.75)
if not loop then break end
	end
end)

This?

local Label = script.Parent

Label:GetPropertyChangedSignal("Visible"):Connect(function()
	if Label.Visible == false then
		return
	end
	while Label.Visible == true do
		Label.Text = "πŸ’¬ Typing πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ .Typing. πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ ..Typing.. πŸ’¬"
		wait(0.75)
		Label.Text = "πŸ’¬ ...Typing... πŸ’¬"
		wait(0.75)
		if Label.Visible == false then
			break
		end
	end
end)

It’s odd since it should break when the condition is met, unless you are spamming it, which probably is what’s going on

Oops, the first script you wrote worked unless you spammed it. Thank you. :slightly_smiling_face:

1 Like

I think you’d maybe have to decrease the time if needed, or prevent people from spamming the button?

If you have anymore issues don’t be afraid to make another post!

1 Like