How can I detect when this script finishes?

so I have a script here.

game.ReplicatedStorage.SendText.OnClientEvent:Connect(function(text)
	script.Parent.Visible = true
	for i = 1, #text do
		script.Parent.Ticker.Text = string.sub(text, 1, i)
		SS.TextWriting:Play()
	    wait(0.04) --This is the speed of the text
	end
end)

But i dont know how to detect once it is done doing all the typewriting effect

Do you have any idea on where I could start on how to fix this?

Well it would be right after the for loop

game.ReplicatedStorage.SendText.OnClientEvent:Connect(function(text)
	script.Parent.Visible = true
	for i = 1, #text do
		script.Parent.Ticker.Text = string.sub(text, 1, i)
		SS.TextWriting:Play()
	    wait(0.04) --This is the speed of the text
	end
    -- Stops right here
end)
1 Like

If you want your client script to yield until the server has finished doing it’s task you can look into using a remote function instead of a remote event. Remote functions work differently compared to remote events as the client waits for the server to finish its function before continuing.

thanks! I feel kinda stupid now for not realizing that lol

1 Like

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