Text animation problem

The problem is that when the animation finishes, the text stay “animated”…

https://gyazo.com/9c79d4a15e8c7a3fe9ff647066f27a18

My script:

local NewText

function setNewText(Text, Inst)
	NewText = Text
	for i=1,#Text do
		Inst.Text = string.sub(Text, 1, i)
		wait()
	end
end

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()

	if game.Lighting.ClockTime >= 7 and game.Lighting.ClockTime < 9 then
		game.StarterGui["CurrentTimeUI"].Local.Frame.TextLabel.Text = "Testing"
		for i, p in pairs(game.Players:GetChildren()) do
			setNewText("Testing", p.PlayerGui["CurrentTimeUI"].Local.Frame.TextLabel)

		end
	end
end)

If you are going for a typewriter effect, I would recommend looking at this: UI Animations | Documentation - Roblox Creator Hub. It uses graphemes to animation text per character.

Same is happening

https://gyazo.com/72b7fff4d8280e7767f6e207f7eef051

AnimateUI.typeWrite(p.PlayerGui["CurrentTimeUI"].Local.Frame.TextLabel, "Testing", 0.05)

You are hooking to “ClockTime”. This will change continuously between 7 and 9 so the connected function will fire indiscriminately at processor/ping speed. Either find a better way to connect the Lighting changes or put some sort of debounce to prevent continuous re-entry into the connected function until it is finished. Or flag entry once and reset it after the time goes beyond the range you require the animation to run only once over.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.