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

Text changer in a SurfaceGui?

Why is this not working? (SurfaceGui)

wait (2)

while true do
	wait (0.5)
	script.parent.TextLabel.Text "Working."
	wait (0.5)
	script.parent.TextLabel.Text "Working.."
	wait (0.5)
	script.parent.TextLabel.Text "Working..."
end

1 comment

1

Because it's broken. Please please give more context, such as the location of everything, the type of script, the output, the expected behaviour and actual behavior, the state of FilteringEnabled, etc etc

1 answer

✓ Accepted answer

You didn't capitalize the property Parent where you wrote script.parent, and you also forgot to make the property Text equal something at the end of lines 5, 7, and 9.

wait(2)

while true do
	wait(0.5)
	script.Parent.TextLabel.Text = "Working."
	wait(0.5)
	script.Parent.TextLabel.Text = "Working.."
	wait(0.5)
	script.Parent.TextLabel.Text = "Working..."
end

I'd like to also point out that there is a simplification that could take place here. Instead of writing the nearly the same thing multiple times over, you can simply use a for loop.

In this example, I use a numeric for loop and string.rep to determine the number of dots I need to concatenate onto the end of "Working".

while true do
	for i = 1, 3 do
		script.Parent.TextLabel.Text = "Working" .. string.rep(".", i)
		wait(0.5)
	end
end

In this slightly simpler example, I use a generic for loop to collect the value of what text should be set to.

local values = {"Working.", "Working..", "Working..."}

while true do
	for _, value in next, values do
		script.Parent.TextLabel.Text = value
		wait(0.5)
	end
end

1 comment

1

Good answer, but just edit the bottom code. You used ' instead of " in the table

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