Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Function is screwing with message:Sub()?

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

✓ Accepted answer

Its :sub not :Sub

That's the only error in your code

2 comments

0

.-. mg thank you so much, lol.

1

@VirusMetic, Lua is case sensitive. If it doesn't work one way, try the other way.

This discussion is preserved as it was. New answers, comments, and votes are closed.