Posted: Fri Jan 18, 2019 7:15 am Post subject: Attempting to compare nil with number (ReadFloat)
Hello
I wrote a script which checks the player's hp (using a pointer), and if it is below 60 it will slowly add back 1 health point (sleep(500)) until it reaches a value.
Code looks something like this:
Code:
while (value < RegenValue)
do
writeFloat(address,value+1)
sleep(500)
end
It works perfectly, except for one thing. When there is a map/level change in the game, the script will error out, attempting to compare nil with number, most likely because between level loads, before the player has spawned, the hp value does not exist.
Thank you for your reply!
I already tried that and it didn't seem to work, because the script stops thanks to the error, I don't want it to stop. I tried using PCall, which made the error disappear, but the script just stops itself.
Let me try something again.
EDIT: Managed to fix it! I changed while(hp < hpregen) to if statements, and added a check if (hp == nil) then it will just repeat itself.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum