It's possible that something is being invalidated at some point. See if this helps:Lejes wrote:There seems to be some kind of problem with this code.
But I can't figure out what it is. It checks if the player is holding a key just fine, but crashes if the player has a Yoshi or turns into a Tanooki statue. The problem seems to be specifically with the line where npcID is declared.Code: Select all
if (player.holdingNPC ~= nil) then local npcID = player.holdingNPC.id if (npcID == 31) then --printText(tostring(v.speedX), 3, 0, 0); --printText(tostring(v.speedY), 3, 0, 32); holding_key = true; end end
Code: Select all
if (player.isValid and player.holdingNPC ~= nil) then
local npcID = player.holdingNPC.id
if (npcID == 31) then
--printText(tostring(v.speedX), 3, 0, 0);
--printText(tostring(v.speedY), 3, 0, 32);
holding_key = true;
end
end









