• isvalid lua error
    2 replies, posted
[CODE]if( !GAMEMODE.Breen or !GAMEMODE.Breen:IsValid() ) then return end[/CODE] [CODE]GM.Breen = { { "models/breen.mdl"}, };[/CODE] [QUOTE]L 03/20/2015 - 08:22:32: Lua Error: attempt to call method 'IsValid' (a nil value)[/QUOTE] I realy dont know what is the problem.
When you try using : on a nil value then it'll tell you the index / key is not valid as it did in other words. The way you wrote it, it is GAMEMODE.Breen[ 1 ] You would also use IsValid( x ) instead of x:IsValid( ) because if x isn't set, then you won't get an error. With the code you posted, IsValid isn't needed... You could use isstring, etc... when comparing but it seems like it's meant to be a simple var... I'd recommend using a different table for models...
[QUOTE=Acecool;47360946]When you try using : on a nil value then it'll tell you the index / key is not valid as it did in other words. The way you wrote it, it is GAMEMODE.Breen[ 1 ] You would also use IsValid( x ) instead of x:IsValid( ) because if x isn't set, then you won't get an error. With the code you posted, IsValid isn't needed... You could use isstring, etc... when comparing but it seems like it's meant to be a simple var... I'd recommend using a different table for models...[/QUOTE] Thank you :)
Sorry, you need to Log In to post a reply to this thread.