I have a gear script and the script works fine but it doesn't know when to stop recording the text so for example if I said

"gear a 130113146" -- Hyperlaser then it would return as

"a 130113146" how would I fix this problem in scripting.

Heres my script

function Getnumber(player,text,message)
local players = game.Players:GetChildren()
local numbers = {"1","2","3","4","5","6","7","8","9"}
local command = string.gsub(string.lower(message),text,"")
local remove1 = string.gsub(string.lower(message),command,"")
local name = string.gsub(remove1,n,"")
if string.sub(text,1,2) == "me" then return 2 end
if string.sub(text,1,3) == "all" then return 3 end
if string.sub(text,1,6) == "others" then return 6 end
if string.sub(text,1,9) == "nonadmins" then return 9 end
if string.sub(text,1,6) == "admins" then return 6 end
for i,v in pairs(players) do local strlower = string.lower(v.Name) local sub = string.sub(strlower,1,2) return #sub end
print(name)
return nil
end


game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(chatted)
		if string.sub(chatted,1,4) == "gear" then
			local number = Getnumber(player,string.lower(string.sub(chatted,6)),chatted)
			print(number)
		end
	end)
end)

3 comments

0

So, what exactly is n in this case? And that gsub will replace the 2nd argument with the 3rd argument. So what i see is, repacing numbers and commabd, with "". Is that intended or nah?

0

Yes to try to narrow down the option but it doesnt work

0

Ok, have you tried other stuff instead of gsub for command? e.g.(gmatch)