#The code throws error

1 messages · Page 1 of 1 (latest)

gray stump
#

Hi, i have a code but it throws it even if there is a line to check if it exists or not, what should i do?

local ownerPlayer = game.Players[singleModel.Parent.Parent:GetAttribute("Owner")]
            
if not ownerPlayer then game.Players:GetPlayerFromCharacter(seat.Occupant.Parent):Kick() end

Error:

invalid argument #2 (string expected, got nil) 
acoustic obsidian
gray stump
#

The first line

#

local ownerPlayer

acoustic obsidian
#

you should print the argument #2 before the variable

#

to see whether it is nil or not

gray stump
#

O yes it is working now thanks

acoustic obsidian
#

does it print nil or what

gray stump
#

i just made

 if singleModel.Parent.Parent:GetAttribute("Owner") == nil then return end

instead of the last line in the first code