What does this mean?

Hello. I saw this and was wondering what this means, but I didn’t find anything on the forum.

function ok(name:string?)

end

Thanks for reading, I appreciate a reply

1 Like

It’s basically just type-casting. You’re telling the script that what is given in that paramter must be a string, it’s typically use if you use the --!strict compiling method, example

--!strict

function ok(name:string?)

end

ok("Test") -- This is fine
ok(1) -- this would tell you that number could not be converted to string

image

By default you would get that unless you add --!strict at the start of your script. It is not really needed to use type-casting yet, but if you want to, you can as it may prove to help out if you run into issues, such as giving it the wrong type it expected

Oh, ok. I wish it actually broke the code so we don’t have to make if-statements every time. Well, thanks for your answer!

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like