# Simple way of making logic variables for all players

**URL:** <https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, fortnite\
**Created:** [September 16, 2023, 8:17pm UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289 "2023-09-16T20:17:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [September 16, 2023, 8:17pm UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/1 "2023-09-16T20:17:14Z")

</div>

I’m trying to make a logic variable for each player and I want to edit it. For example:(if x=y): set Agent’s variable to true. Can help on this, been struggling to make this work

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 16, 2023, 9:01pm UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/2 "2023-09-16T21:01:59Z")

</div>

Hey again, will try to do simpler this time :

```auto
@editable Spawners : []player_spawner_device = array{}

var MyLogicMap : [player]logic = map{}

# In your OnBegin
for (Spawner : Spawners):
    Spawner.SpawnedEvent.Subscribe(OnPlayerSpawned)

# Outside OnBegin
OnPlayerSpawned(Agent: agent):void=
    if(Player := player[Agent]):
        option{set MyLogicMap[Player] = false}

```

You’ll then check your map using :

```auto
if(MyLogicMap[Player]?):
    # Do code

```

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [September 17, 2023, 6:57am UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/3 "2023-09-17T06:57:41Z")

</div>

Yeah I think I understand that now, just one thing, what dot  
you mean by check your map. t  
Thanks a lot for helping

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 17, 2023, 7:07am UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/4 "2023-09-17T07:07:38Z")

</div>

Check that the value of your logic for player is either true or false.

```auto
if(MyLogicMap[Player]?):
    # My Value For Player is TRUE
else:
    # My Value For Player is FALSE

```

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [September 17, 2023, 8:16am UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/5 "2023-09-17T08:16:59Z")

</div>

> [@im\_a\_lama](#):
>
> `if(MyLogicMap[Player]?):`

I’m trying to call that in another function but Player is not defined. Do I need to rewrite this inside of this function?

```auto
if(Player := player[Agent]):
        option{set MyLogicMap[Player] = false}
```

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 17, 2023, 9:02am UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/6 "2023-09-17T09:02:00Z")

</div>

Can you paste the error that’s showing, paste your code too if you can, I’m pretty sure that Player is defined in this case

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [September 17, 2023, 9:31am UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/7 "2023-09-17T09:31:42Z")

</div>

```auto
    OnPlayerSpawned(Agent: agent):void=
        if(Player := player[Agent]):
            option{set DidPlayerVoteMap1[Player] = false}
            option{set DidPlayerVoteMap2[Player] = false}

    voteMgt1(Agent:agent):void=

        if(DidPlayerVoteMap1[Player]?):
            Print("Already voted on this map")
            
        else:
            if(DidPlayerVoteMap2[Player]?):
                set VotesForMap1 += 1
                set VotesForMap2 -= 1
                ScoreManager1.SetScoreAward(VotesForMap1)
                ScoreManager2.SetScoreAward(VotesForMap2)
                Switch1.TurnOn(Agent)
                Switch2.TurnOff(Agent)
            
            else:
                set VotesForMap1 += 1
                ScoreManager1.SetScoreAward(VotesForMap1)
                Switch1.TurnOn(Agent)

```

The votemgt1 function checks for if the player voted if he didnt, does what’s inside else.  
The error is: Unknown identifier ‘Player’

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 17, 2023, 10:41am UTC](https://forums.unrealengine.com/t/simple-way-of-making-logic-variables-for-all-players/1299289/8 "2023-09-17T10:41:10Z")

</div>

> [@nelmi](#):
>
> `if(DidPlayerVoteMap1[Player]?):`

Replace by `if(Player := player[Agent], DidPlayerVoteMap1[Player]?):`

Maybe take a lesson or two about Verse also when you have time because these are pretty basic skills.

Also as an explanation, `Player` is not declared in this scope, you only have access to `Agent`, but you need a `player`. Since `player` variables are children of `agent` variables, you can try to convert from agent to player doing `player[Agent]`
