Weird Subscribe error Occurring

Hey, i’ve been learning verse for maybe a month now and just stubbled uppon this error code in relation with the subscribe function I’ve never seen before.

CheckIfLeft(Agent: agent)<suspends>:void=
        loop:
            Sleep(0.0)
            if (Self.MaybeCorPlayer = TycoonAsset.AgentToCustomPlayer[Agent].LeavingPlayer):
                Print("yes, its him!")    

executed like:

for(Obj:ClassSelector):
            Obj.ClassSelector.TeamSwitchedEvent.Subscribe(Obj.SetMaybeCorPlayer)
            Obj.ClassSelector.TeamSwitchedEvent.Subscribe(Obj.CheckIfLeft)    #   BROKEN

error:

The error is telling you that Subscribe not expecting a function with the <suspends> effect.

You will need to spawn the suspends function in your event handler

CheckIfLeft(Agent: agent)<suspends>:void=
    loop:
        Sleep(0.0)
        if (MaybeCorPlayer = TycoonAsset.AgentToCustomPlayer[Agent].LeavingPlayer):
            Print("yes, its him!")
            break

OnTeamSwitched(Agent:agent):void =
    spawn{CheckIfLeft(Agent)}
for (Obj : ClassSelector)
    Obj.ClassSelector.TeamSwitchedEvent.Subscribe(Obj.SetMaybeCorPlayer)
    Obj.ClassSelector.TeamSwitchedEvent.Subscribe(Obj.OnTeamSwitched)
1 Like

Thanks man, makes sense and fixed my code so far! <3