Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why isn't the text being put in the textlabel in a typewriter effect?

Asked by 4 years ago
Edited 4 years ago

(This is a repost, don't worry I deleted the original post)

local text = script.Parent.Text
local status = script.Parent.StatusValue.Value

if text ~= status then
    for i = 1, string.len(status) do
       text = string.sub(status, 1, i)
      wait(0.04) --This is the speed of the text
    end
end

Hello there, my problem is that the text isn't even appearing and the text that was originally there stays there. I've tried fixing this, and yet it isn't working and I have no idea as of why it isn't. I mean, I've gotten to the point of changing the status variable to camelCase cause I have no idea.

This is a script (I've tried changing it to a local script and it hasn't worked either) in a text label named "TextStatus" which also has a string value named "StatusValue" which will hold the status (text) that is supposed to be in the text variable in "TextStatus"

Thank you for reading this,

Narwhal

EDIT: I'm new to this "for i = 1, string.len(status) do" stuff, also "for i,v in pairs do" (sorry if I said it wrong), type stuff. also thanks for help RiskoZoSlovenska! '

0
the error means that for the "for i=1, string.len(status)" line, "string.len(status)" cant be a limit because its a string, not a numbervalue. i consider translating the string to numbervalue so it can work. speedyfox66 237 — 4y
0
sorry i forgot to get rid of that, that error was from the earlier script (this was edited from advie from RiskZoSlovenska) NarwhalAndMe 141 — 4y

1 answer

Log in to vote
2
Answered by
Nanomatics 1160 Moderation Voter
4 years ago

Your code is actually perfectly fine except for one part.

The text variable is your problem because you are referring to the TextLabel's text and storing it inside a variable, so when you change that variable, you think you are changing the text, but you are actually just changing the variable.

To fix this you just have to define text as

local text = script.Parent

Then when you are trying to modify the text, you add the .Text in there

if text.Text ~= status then -- here
    for i = 1, string.len(status) do
       text.Text = string.sub(status, 1, i) -- and here
      wait(0.04) --This is the speed of the text
    end
end

That should fix it, if you have any questions please let me know

0
Thanks it worked! NarwhalAndMe 141 — 4y
Ad

Answer this question