How do you check if a variable is a string? I can’t seem to get this to work.
local CheckString = function(userdata)
local userdata = tostring(userdata) -- set "userdata" to a string
if userdata == typeof(string) then
print("String!")
else
print("Not string!")
end
end
if you wanted a quick explanation. userdata == typeof(string) will never be true because typeof(string) will return "table" as a string, but since i’m guessing tostring(userdata) in this case is never “table” then "table" ~= userdata
The check you’re doing is redundant. CheckString will always print the true case, because tostring always returns a string, and you’re checking if tostring’s return was a string.