Table id errors nil?

Im confused on why this code isnt working, even though i type the third arg as 1 it still errors as nil


local Bosses = {
	game.ReplicatedStorage:WaitForChild("Bosses"):WaitForChild("KingOKnights"),
}

game.Players.PlayerAdded:Connect(function(plr)
	for _,v in pairs(Admins) do
		if plr.Name == v then
			plr.Chatted:Connect(function(msg)
				local loweredString = string.lower(msg)
				local args = string.split(loweredString," ")
				
				if args[1] == Prefix.."spawnboss" then
					for _,player in pairs(game:GetService("Players"):GetPlayers()) do
						if string.sub(string.lower(player.Name), 1, string.len(args[2])) == string.lower(args[2]) then
							
							local bossid = args[3]
							
							local bossclone = Bosses[bossid]:Clone() --code is erroring here
							bossclone.Parent = workspace
							bossclone.PrimaryPart.CFrame = player.Character.PrimaryPart.CFrame
							
							print(args[3]) --this prints out 1
						end

					
					end
				end
				
			end)
		end
	end
end)

What line is the error located?

(ignore)

You definitely need to include more information. The input string, the exact error, etc. As it happens though, I think it’s because args[3] is a string, not a number. Use this instead. local bossid = tonumber(args[3])

1 Like