Hey, I have a problem with a Verse code I’m using. It’s a Health Modifier code that allows players to modify their own health and shield values. The issue is that this code only targets individual players, meaning only one player can modify their health independently. What I want is for the code to apply to all players at the same time, so when one player modifies their health, all players’ health gets modified simultaneously. Can anyone help me adjust the code to make this work?
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /Verse.org/Verse }
health_modifier_device := class(creative_device):
@editable
IncreaseHealthTrigger : trigger_device = trigger_device{}
@editable
DecreaseHealthTrigger : trigger_device = trigger_device{}
@editable
IncreaseShieldTrigger : trigger_device = trigger_device{}
@editable
DecreaseShieldTrigger : trigger_device = trigger_device{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
# TODO: Replace this with your code
IncreaseHealthTrigger.Enable()
DecreaseHealthTrigger.Enable()
IncreaseShieldTrigger.Enable()
DecreaseHealthTrigger.Enable()
IncreaseHealthTrigger.TriggeredEvent.Subscribe(IncreasePlayerHealth)
DecreaseHealthTrigger.TriggeredEvent.Subscribe(DecreasePlayerHealth)
IncreaseShieldTrigger.TriggeredEvent.Subscribe(IncreasePlayerShield)
DecreaseShieldTrigger.TriggeredEvent.Subscribe(DecreasePlayerShield)
# HEALTH
# Function to increase Health by 10
IncreasePlayerHealth(Agent : ?agent): void =
var players: []player = Self.GetPlayspace().GetPlayers()
if(CurrentPlayer := players[0]):
if(PlayerCharacter : fort_character = CurrentPlayer.GetFortCharacter[]):
PlayerCharacter.SetHealth(PlayerCharacter.GetHealth() + 10.0) # Enter amount to increase Health
Print("Health increased")
# Function to decrease Health by 10
DecreasePlayerHealth(Agent : ?agent): void =
var players: []player = Self.GetPlayspace().GetPlayers()
if(CurrentPlayer := players[0]):
if(PlayerCharacter : fort_character = CurrentPlayer.GetFortCharacter[]):
PlayerCharacter.SetHealth(PlayerCharacter.GetHealth() - 10.0) # Enter amount to decrease Health
Print("Health decreased")
# SHIELD
# Function to increase Shield by 10
IncreasePlayerShield(Agent : ?agent): void =
var players: []player = Self.GetPlayspace().GetPlayers()
if(CurrentPlayer := players[0]):
if(PlayerCharacter : fort_character = CurrentPlayer.GetFortCharacter[]):
PlayerCharacter.SetShield(PlayerCharacter.GetShield() + 10.0) # Enter amount to increase Shield
Print("Shield increased")
# Function to decrease Shield by 10
DecreasePlayerShield(Agent : ?agent): void =
var players: []player = Self.GetPlayspace().GetPlayers()
if(CurrentPlayer := players[0]):
if(PlayerCharacter : fort_character = CurrentPlayer.GetFortCharacter[]):
PlayerCharacter.SetShield(PlayerCharacter.GetShield() - 10.0) # Enter amount to decrease Shield
Print("Shield decreased")