Page 1 of 1

PLEASE HELP ME! player.character

Posted: Tue Apr 25, 2017 3:50 am
by Stx3
Heelo!
After update to 0.15.x i cant use command player.character
Attemp to index field "character" (a nil value)

Code: Select all

character
Type: Lua/Character

The character controlled by this player.

   game.player.character.health = 50
   local character = game.player.character -- store the pointer to the character
   game.player.character = nil -- disconnect the character, player will gain ghost view
   game.player.character = character -- connect player to the character again
please help me!

Re: PLEASE HELP ME! player.character

Posted: Tue Apr 25, 2017 3:54 am
by Stx3
in pvp mode player dont have a character! lol thx)))

Re: PLEASE HELP ME! player.character

Posted: Tue Apr 25, 2017 6:17 am
by Rseding91
"game.player" isn't valid in mods since 0.13.0.

You have to reference some specific player - or iterate all players. All events related to a player will contain player_index as a property which you can use with game.players[index] to work on that player.