KillStreak

so i did this, i know its wrong but im stucked, i want to play the hud message on everyone in the lobby that says something like “Peter is in killstreak of 20 kills”. i dont know if im missing something

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

Killstreak := class(creative_device):

@editable
HUD:hud_message_device = hud_message_device:


# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=

    AllPlayers := GetPlayspace().GetPlayers()
    for (EliminationGamePlayer : AllPlayers):
        if (FortCharacter := EliminationGamePlayer.GetFortCharacter[]):
            FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated) # subscribe to eliminated event

OnPlayerEliminated(Result:elimination_result):void=
    Print("Player Eliminated")
    EliminatingCharacter := Result.EliminatingCharacter
    if (FortCharacter := EliminatingCharacter?):
        var killCount : int +=1
        if (killCount > 2):
            HUD.Show()

This code will not initially work adequately in multiplayer. Here is the code for a solo game with one counter for all players. You need to make a counter for each player.

@editable
HUD:hud_message_device = hud_message_device:
var killcount : int = 0 ####initialize the variable here

# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=

    AllPlayers := GetPlayspace().GetPlayers()
    for (EliminationGamePlayer : AllPlayers):
        if (FortCharacter := EliminationGamePlayer.GetFortCharacter[]):
            FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated) # subscribe to eliminated event

OnPlayerEliminated(Result:elimination_result):void=
    Print("Player Eliminated")
    EliminatingCharacter := Result.EliminatingCharacter
    if (FortCharacter := EliminatingCharacter?):
        set killCount : int +=1 #### set the variable here
        if (killCount >= 2):
            HUD.Show()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.