I want this:
local randomString = "Random"
if randomString = **string** then print("Its a string!") else print("Its isn't a string!") end
But how to release this script, to work it?
Use type. Type
will return table
, string
, number
, boolean
, or userdata
if it's one.
local randomString = "Random"
if type(randomString) == "string" then
print("Its a string!")
else
print("Its isn't a string!")
end
Using type()
will help you here!
Here's some code I put through lua and the results to help you out:
local f = 1 local sa = "1" print(type("fsa")) print(type(f..sa)) print(type(f)) print(type(sa)) print(type(function() print("foobar") end))
Output:
string
string
number
string
function
For example:
if(type("string") == "string") then print("foo") else print("bar") end
Output:
foo
If you need any help just ask! :D