Making player invisible by holding keycard not working...

I have been trying to fix this for about an hour now but I am not the best at programming as I am still a beginner, can you tell me whats wrong with my code:

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

InvisDevice := class(creative_device):

    @editable
    CardDetector : conditional_button_device = conditional_button_device{}

    @editable
    PlayerSpawner : player_spawner_device = player_spawner_device{}

    


    OnPlayerSpawned(Agent : agent):void=    
        

        spawn:
            CheckForCard()
    CheckForCard()<suspends>:void=
        loop:
            Sleep(0.2)
            AllPlayers:=GetPlayspace().GetPlayers()      
            for(Player:AllPlayers):
                if(IsAgent:agent = agent[Player]):
                    if(CardDetector.IsHoldingItem[IsAgent]):
                        Print("holding")
                        HidePlayer(IsAgent)
                    else:
                        Print("not holding")
                        ShowPlayer(IsAgent)

ShowPlayer(Agent:agent):void=
    if(FC:=Agent.GetFortCharacter[]):
        FC.Show()

HidePlayer(Agent:agent):void=
    if(FC:=Agent.GetFortCharacter[]):
        FC.Hide()

Hi, OnPlayerSpawned is never called, you should subscribe to the player spawner event, put this inside your OnBegin function :

PlayerSpawner.SpawnedEvent.Subscribe(OnPlayerSpawned)

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