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

How would i do this text thing with a script?

Asked by 9 years ago

I've seen games where it displays text one character at a time, even when it is using strings like this:

t  =  ..game.Workspace.Part.Rotation.."CoolDudeGuyMan"

how would I do this in my scripts? Is there something so obvious I'm missing?

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Do you mean like type the text out?

If so then what you need to do is first make a constant loop, a while loop;

while wait() do --You can just put wait in the definition of the while

end

Now, you need to have a for loop to type out the string one by one, but don't forget to define the string.

The definition of your string will need to involve the concatenation of the property's value.

--[[Because the rotation property is actually a userdata value, you cannot directly concatenate it.. so you need to concatenate all of the elements]]
local p = workspace.Part
local Str = p.Rotation.X..", "..p.Rotation.Y..", "..p.Rotation.Z.." CoolDudeGuyMan"

--Now make the for loop. Substitude the end increment for the length of 'Str'.
for i = 1,#Str do
    --Now get the part of the string that correlates to the for's iteration
    t = Str:sub(0,i)
    print(t)
    wait(.1) --This is the yeild between letters
end

Now put the for loop inside the while loop.

while wait() do
    local p = workspace.Part
    local Str = p.Rotation.X..", "..p.Rotation.Y..", "..p.Rotation.Z.." CoolDudeGuyMan"
    for i = 1,#Str do
        t = Str:sub(0,i)
        print(t)
        wait(.1)
    end
end
Ad

Answer this question