I have a problem with my code, what can I do to make it work?

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

A Verse-authored creative device that can be placed in a level

enemy_detector_device := class(creative_device):

@editable
Button : button_device = button_device{}

@editable
EnemyImage : texture_2d = DefaultTexture2D # Replace DefaultTexture2D with your actual enemy image asset

var PlayerUI : player_ui = player_ui{} # The UI for the player

OnBegin<override>()<suspends>:void=
    Button.InteractedWithEvent.Subscribe(OnButtonClicked)
    
OnButtonClicked(InPlayer:agent):void=
    NearestEnemy := FindNearestEnemy(InPlayer)
    if (NearestEnemy):
        ShowEnemyImage(InPlayer)

FindNearestEnemy(Player:agent) : ?agent =
    NearestEnemy : ?agent = false
    MinDistance := 999999.0
    for (OtherPlayer : GetPlayspace().GetPlayers()):
        if (OtherPlayer.GetTeam() <> Player.GetTeam()):
            Distance := Vector3Distance(Player.GetTransform().Translation, OtherPlayer.GetTransform().Translation)
            if (Distance < MinDistance):
                set MinDistance = Distance
                set NearestEnemy = option{OtherPlayer}
    NearestEnemy

ShowEnemyImage(Player:agent) : void =
    if (PlayerUI := GetPlayerUI[player[Player]]):
        EnemyImageWidget := image{Texture := EnemyImage}
        PlayerUI.ShowWidget(EnemyImageWidget)

you should post the error you receive if any

also a brief description of what the code is or isnt doing

try adding print statments to your code so you can see it executing in game. You may find your code works and it is an issue with an asset. Widgets can be obscured or not even show up if the are displayed on the same layer as another widget at the same time.

ps. welcome to the comunity!