Tween Frame and then Typewriter Effect

hii! i am trying to create a cool gui npc dialogue. so when the player clicks a gui button, a gui frame will tween to the screen. when it finishes tweening, i want the text appear with a typewriter effect. i have a script but i am not sure why it is not working.

gui.MouseButton1Click:Connect(function()
	frame:TweenPosition(UDim2.new(0.378, 0, 0.465, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1):Play()
	wait(1)
	for i = 1, #text do
		typewriter.Text = string.sub(text, 1, i)
		wait(0.04)
	end
end)

any help is appreciated!! <33

It seems alright but I don’t know why it won’t work. Have you created variables for the gui, frame and stuff?

An easier way to do this would be to use MaxVisibleGraphemes property on the TextLabel, which is made specifically for typewriter effects.

A few other notes, instead of MouseButton1Click, use Activated. And instead of wait() use task.wait() trust me its way better.

1 Like

:TweenPosition function does not need to be :Play'ed
Remove :Play() at the end of the 2nd line.
Also I recommend you to use MaxVisibleGraphemes property as @KdudeDev said.

1 Like

ahh!! i removed the :Play() and it worked perfectly! thank u sm!! <33

1 Like

Can you mark my post as solution then? :grin:

1 Like

ahh sorry about that! must have forgotten! just did it <33

1 Like