Fortnite freeze gun only works if health is damaged.

Using this verse code a player should become frozen if damaged by a specific weapon, for some reason this only works when damaging health (does not work on shield).

using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }

freeze_device := class(creative_device):
    
    @editable ConditionalButton : conditional_button_device = conditional_button_device{}
    @editable FreezeTime : float = 3.0

    OnPlayerDamaged(DamageResult : damage_result): void :=
        if:
            Instigator := DamageResult.Instigator?
            Agent := Instigator.GetInstigatorAgent[]
            ConditionalButton.IsHoldingItem[Agent]
            Target := fort_character[DamageResult.Target]
    
        then:
            spawn:
                FreezePlayer(Target)

    FreezePlayer(Target : fort_character)<suspends> : void :=
        Target.PutInStasis(stasis_args{})
        Sleep(FreezeTime)
        Target.ReleaseFromStasis()

    OnBegin<override>()<suspends> : void :=
        for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[]):
            FortCharacter.DamagedEvent().Subscribe(OnPlayerDamaged)

using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/UI }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }

freezegun := class(creative_device):

@editable ConditionalButton : conditional_button_device = conditional_button_device{}
@editable FreezeTime : float = 1.0

OnPlayerDamage(DamageResult : damage_result): void =
    if:
        Instigator := DamageResult.Instigator?
        Agent := Instigator.GetInstigatorAgent[]  
        ConditionalButton.IsHoldingItem[Agent]
        Target := fort_character[DamageResult.Target]

    then:
        spawn: 
            FreezePlayer(Target)

FreezePlayer(Target : fort_character)<suspends> : void =
    Target.PutInStasis(stasis_args{})
    Sleep(FreezeTime)
    Target.ReleaseFromStasis()

OnPlayerAdded(Player : player) : void =
    if (FortCharacter := Player.GetFortCharacter[]):
        FortCharacter.DamagedEvent().Subscribe(OnPlayerDamage)  

OnBegin<override>()<suspends> : void =
    GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)
    for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[]):
        FortCharacter.DamagedEvent().Subscribe(OnPlayerDamage)
1 Like

not work for me

What’s the difference? Can’t get it to work either. Any tips?

Your script has incorrect logic and is poorly indented. I assume you copied the fix above. Follow the correction I made.
I will post the scripts I correct on my Twitter: https://twitter.com/galinhe1080

using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }

freeze_device := class(creative_device):
    
    @editable ConditionalButton : conditional_button_device = conditional_button_device{}
    @editable FreezeTime : float = 3.0

    OnPlayerDamaged(DamageResult : damage_result): void :=
        if:
            Instigator := DamageResult.Instigator?
            Agent := Instigator.GetInstigatorAgent[]
            ConditionalButton.IsHoldingItem[Agent]
            Target := fort_character[DamageResult.Target]
    
        then:
            spawn:
                FreezePlayer(Target)

    OnPlayerDamagedShield(DamageResult : damage_result) : void :=
        if:
            Instigator := DamageResult.Instigator?
            Agent := Instigator.GetInstigatorAgent[]
            ConditionalButton.IsHoldingItem[Agent]
            Target := fort_character[DamageResult.Target]
            
        then:
            spawn:
                FreezePlayer(Target)

    FreezePlayer(Target : fort_character)<suspends> : void :=
        Target.PutInStasis(stasis_args{})
        Sleep(FreezeTime)
        Target.ReleaseFromStasis()

    OnBegin<override>()<suspends> : void :=
        for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[]):
            # Inscrever-se em DamagedEvent
            FortCharacter.DamagedEvent().Subscribe(OnPlayerDamaged)
            # Inscrever-se em DamagedShieldEvent
            FortCharacter.DamagedShieldEvent().Subscribe(OnPlayerDamagedShield)

But If I’m holding the freezeweapon, I get freezed while taking stormdamage.
I guess it has something to do with Instigator := DamageResult.Instigator?
Any tips?

I’ve been testing the code all night, I haven’t been able to find a solution. It seems like the logic of the script makes the storm an “Agent.” I’ll do more testing, I’ll let you know if anything happens.

DamagedEvent will be called by any damage done to the player. Even if you do fort_character.Damage(1.0) from script. So you would have to make some logic var

Something like if Instigator = True then do script. If false do nothing.

The storm is not an agent so it would turn out false.

Hope it helps

1 Like

i have Code here :

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Random }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation/Tags }
using { /UnrealEngine.com/Temporary/UI }
using { /Verse.org/Colors/NamedColors }
using { /UnrealEngine.com/Temporary/SpatialMath }

#FNMC_CREATIVES property

freeze_device := class(creative_device):

    @editable ConditionalButton : conditional_button_device = conditional_button_device{}
    @editable FreezeTime : float = 2.0

    OnPlayerDamage(DamageResult : damage_result): void =
        if:
            Instigator := DamageResult.Instigator?
            Agent := Instigator.GetInstigatorAgent[]
            ConditionalButton.IsHoldingItem[Agent]
            Target := fort_character[DamageResult.Target]

        then:
            spawn:
                FreezePlayer(Target)

    FreezePlayer(Target : fort_character)<suspends> : void =
        Print("Frozen")
        Target.PutInStasis(stasis_args{})
        Sleep(FreezeTime)
        Target.ReleaseFromStasis()
        Print("UnFrozen")


    OnPLayerAdded(Player : player) : void =
        if (FortCharacter := Player.GetFortCharacter[]):
            FortCharacter.DamagedEvent().Subscribe(OnPlayerDamage)

    OnBegin<override>()<suspends> : void =
            GetPlayspace().PlayerAddedEvent().Subscribe(OnPLayerAdded)
            
            for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[]):
                FortCharacter.DamagedEvent().Subscribe(OnPlayerDamage)