I am making admin commands, and I am making a apostraphe identifier. It works but it skips the first one, any help?

function findrt(message, var)
skips = 0 
maxs = var
spaces = {}
apos = {}
lastn = {}
num = 0
last = 0
player = {}
other = {}
--Space Checks---
for i = 1, message:len() do
	wait()
	last = last+1
	if message:sub(i,i) == " "
		then
		num = num+1
		if num > skips and num < maxs+1
			then
		table.insert(spaces, #spaces+1,i+1)
		table.insert(lastn, #lastn+1,last)
		last = 0
	end
	end
end

print("Checking "..#spaces.." Spaces")
for i = 1, #spaces do
	subs = message:sub(spaces[i],lastn[i]+spaces[i])
	local check = true
	print(subs)
--Most likely where to problem is
	local last2 = 0
	if string.find(subs,",") ~= nil
		then
		print("Found Apos", string.find(subs,","))
		for i = 1, subs:len() do
			local last2 = last2+1
			if subs:sub(i,i) == ","
				then
				newsub = subs:sub(i+1,last2+i)
				print(newsub)
				table.insert(apos,#apos+1,newsub)
				last2 = 0
			end
		end
		check = false
		end
	if check == true
		then
	print("Checking")
	a = game.Players:GetChildren()
	for b = 1, #a do
		if string.find(string.lower(a[b].Name), string.lower(subs)) ~= nil
			then
			if i == 1
				then
			table.insert(player,#player+1, a[b])
			break
			end
			if i > 1
				then
			table.insert(other,#other+1, a[b])
			break
		end
		end
	end
	end
end

if other ~= nil
	then
	return player, other
else if other == nil
	then
	return player
end
end
end

players = findrt(";kill a,b,c", 1)
for i = 1, #players do
	print(players[i])
end

the out put for this is a,b,c b c

3 comments

0

Move your then keywords to the same line as their if counterparts, first of all, just so it's easier to read. I can't tell what's doing what, when because of your formatting.

0

All devs have different ways to code :0

1

It's better than no tabbing at all, that's much harder to read. You really should make ALL of the tabbing  correct, though.