Code: public function onTap(PlayerInteractEvent $event) { $user = $event->getPlayer(); $item = $event->getItem(); $player = $event->getPlayer(); if ($item->getId() == 280) { $player->setMaxHealth(50); $player->setHealth(50); $player->sendMessage('§a»§8'.$player->getName().'§e'.self::NAME_GAME.'§8:§a'.$player->getFolderName()); } } Not found helpme
1) In your use statements, do PHP: use pocketmine\event\player\PlayerInteractEvent; 2) Your $user variable looks like it’s unused and you use $player variable instead, you can remove that. 3) Don’t use loose checks, do strict checks & use constants for items. PHP: if($item->getId() === Item::STICK) 4) I’d hope you only want to set the player’s health and not change how much health they can have to 50, you’ll want to remove PHP: $player->setMaxHealth(50); if that’s the case.
Can you send the updated function so we can make sure you correctly fixed the issues @notdrewdev pointed out?
What is '$player->getFolderName()' it supposed to be $player->getLevel()->getFolderName() I think that's why your server crashed.