I'm creating a script that simply looks for the player's userids, what guns there allowed to spawn, and how many spawns they have left. The script seems to stop reading things correctly past if table.find(owners, plr.UserId) then which is that part that looks for the players userid.
local adminguns = {"G26L","G17"} local owners = {"46315828"} local amount = 10 game.Players.playerAdded:Connect(function(plr) plr.Chatted:Connect(function(message) print("plrchat") if message and string.sub(message, 1, 7):lower() == "/spawn " then print("plrsaidspawn") if table.find(owners, plr.UserId) then print("plrfound") if table.find(adminguns, string.sub(message, 7)) then print("admingunfound") if amount > 0 then print("amountmorethanzero") local firearms = game.ServerStorage.Assets:WaitForChild("Firearms") if firearms:FindFirstChild(string.sub(message, 7)) ~= nil then print("weaponnotnil") local spawn = firearms:FindFirstChild(string.sub(message, 7)):Clone() spawn.Parent = plr.Backpack amount = (amount - 1) print("worked!") end end end end end end) end)
You're finding a number (plr.UserId) in a table with string, which is why it won't work. You'll have to turn the user id to a string, or replace the string in table with a number. You can turn the user id to the string, use tostring(plr.UserId)
if table.find(owners, tostring(plr.UserId)) then
or you can just make the string in table a number
local owners = {46315828}