Typewriter script not working on SurfaceGui

I’m trying to make a script that writes text similar to a typewriter with one word at a time. I want to change it to fit on a SurfaceGui but it does not work. Here’s the script:

local text = "TestText"

for i = 1, #text do 
    script.Parent.TextLabel.Text = string.sub(text, 1, i)
    wait()
end

For some reason the text does not appear on a SurfaceGui but it does appear on a ScreenGui. Anyone know what’s up?

1 Like

Did you placed the SurfaceGui in the right direction?
It could be that you faced it in the wrong direction so you can’t see it from the side you are looking on it

No, it is on the right side (by Right side I mean Front) so it is definitely visible.

Did you try to just use a normal textlabel on it without any script?

Can you screenshot the explorer? Maybe it’s in the wrong hierarchical order

I don’t have screenshots but I can just explain it through text.

Part
SurfaceGui

LocalScript
TextLabel

Does that make sense?

Oh wait I didn’t see that it was a LocalScript. That’s the problem.

That’s the problem. LocalScripts do not run in Workspace. Switch this with a server script and see if it works.

LocalScripts do not run in places outside of ReplicatedFirst, a descendant of player (PlayerGui, Backpack, etc), or the player’s character. As much as I hate using Scripts to manipulate UI, a Script is your only choice here. You could even do it client-side by putting the LocalScript in an appropriate location.