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

Function is screwing with message:Sub()?

Asked by 8 years ago

Alright, this script takes a target of a string and prints it out one by one, however, I'm getting an error and I'm not sure why.

Not working

MainDest = script.Parent.speechLabel

String = "Why this no work.."

function Speak(message, target)
    for i = 1, message:len() do
        wait()
        target.Text = message:Sub(1,i)
    end
end

wait(1)
Speak(String, MainDest)

Error:

8: attempt to call method 'Sub' (a nil value)


Working without function

for i = 1, String:len() do
wait()
Message.Text = String:sub(1,i)
end

Any help would be great! Thanks!

1 answer

Log in to vote
1
Answered by 8 years ago

Its :sub not :Sub

That's the only error in your code

0
.-. mg thank you so much, lol. WelpNathan 307 — 8y
1
@VirusMetic, Lua is case sensitive. If it doesn't work one way, try the other way. M39a9am3R 3210 — 8y
Ad

Answer this question