There isn't without re writing your code every where. I have one temporary solution and one permanent solution for future use.
Temporary to quick fix your problem
Global Var HPTransition
On Layout End
-- HPTransition = player.health
on Layout Start
-- player.health = HPTransition
OR
Dictionary Object name Global
On Layout End
-- Global.set("HP", player.health)
on Layout Start
-- player.health = Global.get("HP")
Long term solution.
Whenever creating your game and you either need to check or change a value for players, enemies or objects. Create a Group Object with functions to use as Getters and Setters.
Player Functions // this is a group
OnFunction "fPlayer.getHP"
OnFunction "fPlayer.addHP"
- player.hp + Fn.Param(0) // -num will work as subtraction for add&sub
Using said functions. Never use any other form of accessing the players.hp. Only use the getter and setter function
Event collision with enemy
-- FunctionCall( "fPlayer.addHP", -10)
Event collision with hazard
-- FunctionCall( "fPlayer.addHP", -5)
-- FunctionCall("check death")
Event collision with health restore
-- FunctionCall( "fPlayer.addHP", 20)
OnFunction "CheckDeath"
-- if(Function.Call(fPlayer.getHP) <= 0)
---- do deeath stuff
As you can see none of your game logic every looks at or modifies your player HP outside of the dedicated functions. This means that if you need to transition your variable player.hp to global hp you can with minimal effort
Player Functions // after modification
global var HP
OnFunction "fPlayer.getHP"
OnFunction "fPlayer.addHP"
- HP + Fn.Param(0) // -num will work as subtraction for add&sub
good luck :) If your project is big. it's worth going over an applying organized code structure. If it's a smaller project, then just hack what you need :)