Functions not working, HELP!

I was scripting and i came across a bug, after alot of testing i found out that one of the following two functions doesnt work right, please help.

--N from Stack
local function NfromS(List, n)
	for N, Y in ipairs(List) do
		if N == n then
			return Y
		end
	end
end
--String to number
local function NUMBER(O)
	local tmp = 0
	repeat
		if O == string.lower(tmp) then
			return tmp
		end
		tmp += 1
	until string.len(O) < string.len(tmp)
	return 0
end

what is supposed to happen with these two functions?

the function NfromS is supposed to get an item N from a list and return it
the function NUMBER is supposed to convert a string to a number (if it is)

Why are you not calling the functions?

Show example with tables.

to convert string to number
use the tonumber("52") function

to get n from list use table.find(myTable, "NMyCoolEpic")

i do, but thats not the problem, as i stated before one of them doesnt work right, but idk which one

Are you using weird functions on purpose? Those can be really simplified and optimized to just those:

local function NfromS(list: {}, n: number): any
	return list[n]
end

local function NUMBER(s: string): number?
	return tonumber(s)
end
1 Like

black magic for me, im not that good at programming that i know how to use things like this so good.
anyways im gonna try these out and mark them as a solution if it works!

im just gonna make a new post regarding my script…
i hate this…

btw: the shortcuts do work, but its something else thats also causing problems…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.