Find a word in a parameter

I have tried string.find, string.sub, and string.split but it would only print this; table: 0x6c4beacf9dc299fc is there any way I could make it print the ABC.

local function Test(Goal)
	local makestring = tostring(Goal)
	print(Goal)
	--local makestring = tostring("abc = 123")
	local str = string.sub(makestring, 1, 100)--string.split(makestring, "=")
	print(str)
	--print(str[1])
end

Test({ABC = 123})

1 Like

You could use unpack to get the table’s values as a tuple, where you could print the contents, instead of it’s memory address.

Example:

local MyTable = {A, B, C}
local MyValues = table.unpack(MyTable)

print(MyValues) --> A,B,C
1 Like

tables cannot be serialized with tostring. The simplest way to serialize would be to use JSON.

local HttpService = game:GetService("HttpService")

local function Test(Goal)
	local makestring = HttpService:JSONEncode(Goal)
	print(Goal)
	--local makestring = tostring("abc = 123")
	local str = string.sub(makestring, 1, 100)--string.split(makestring, "=")
	print(str)
end

Test({ABC = 123})

You can also de-serialize using the same service.

What does table unpack do also how does this work?

table.unpack returns all of the values in an array.

It works but how would I get what the string equals to (123)?

Nevermind got it. But for some reason the the table.unpack does not work but the http service does.