# Some players are not being teleported using Verse (teleport device)

**URL:** <https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [October 30, 2024, 1:34pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782 "2024-10-30T13:34:03Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rak\_Bibi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rak\_Bibi](https://forums.unrealengine.com/u/Rak_Bibi)\
**Post date:** [October 30, 2024, 1:34pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/1 "2024-10-30T13:34:03Z")

</div>

hi guys… i have an issue.

it is a published map!

I use teleport devices to move players to specific locations. I loop through all the players and teleport each one right away, but sometimes one or two players don’t get teleported. What might be going wrong?

this is the code i used:

```auto
 set Team_Manage.TeleporterNum = 0

 for (Player : GetPlayspace().GetPlayers()):
      TeleportToTeamSelection(Player)
      set Team_Manage.TeleporterNum += 1

```

and now i want to test the code below but before i publish the changes i want to ask you guys if it is a known issue?

 ![2024-10-30 152326](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/0/7f0362c09c5a4b66f820a96b0b5d6084c807d77e.png)

---

<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:** [October 30, 2024, 4:15pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/2 "2024-10-30T16:15:42Z")

</div>

You’re incrementing `TeleporterNum` twice, so you’re probably ending up trying to fetch a teleporter that doesn’t exist in the array, also you might want to use this method to avoid fetching indexes out of array length

```auto
# Returns the remainder of `X/Y` as defined by Euclidean division, i.e.:
# * `Mod[X,Y] = X - Quotient(X/Y)*Y`
# * `0 <= Mod[X,Y] < Abs(Y)`
# Fails if `Y=0`.
Mod<native><public>(X:int, Y:int)<computes><decides>:int

```

---

<div class="post-metadata">

**Author:** ![Rak\_Bibi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rak\_Bibi](https://forums.unrealengine.com/u/Rak_Bibi)\
**Post date:** [October 30, 2024, 11:07pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/3 "2024-10-30T23:07:22Z")

</div>

I’m pretty new to Verse and programming in general, so I’m having a bit of trouble understanding the code you sent.

Here’s what I used when I ran into the issue

```auto
OnGame_Start_Timer_Success(Agent : ?agent) : void =

set Team_Manage.TeleporterNum = 0

for (Player : GetPlayspace().GetPlayers()):
     TeleportToTeamSelection(Player)
     set Team_Manage.TeleporterNum += 1

```

where do i incrementing `TeleporterNum` twice ? what am i missing ?

---

<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:** [October 31, 2024, 9:20am UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/4 "2024-10-31T09:20:30Z")

</div>

```auto
set Team_Manage.TeleporterNum = Mod[Team_Manage.TeleporterNum + 1, TeamSelectionTeleportersArray.Length]

```

This way you don’t overflow the index, search for modulo operator on internet

---

<div class="post-metadata">

**Author:** ![Rak\_Bibi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rak\_Bibi](https://forums.unrealengine.com/u/Rak_Bibi)\
**Post date:** [October 31, 2024, 10:10am UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/5 "2024-10-31T10:10:58Z")

</div>

I looked it up, and I see now. This will cycle back to the first teleporter in the array once it hits the last one.  
This is really useful. I can apply it to other things. Thanks!

Honestly, I still don’t quite see where the double increment is happening. I’ve got 16 teleporters in the map of max 16 players, yet even with only 4 players, sometimes one isn’t teleported so i dont know what to think. I’m more curious about why this is happening than focused on fixing it lol

---

<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:** [October 31, 2024, 1:07pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/6 "2024-10-31T13:07:20Z")

</div>

I think it’s just that you posted 2 different codes in your first post and I got confused 👍

---

<div class="post-metadata">

**Author:** ![Rak\_Bibi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rak\_Bibi](https://forums.unrealengine.com/u/Rak_Bibi)\
**Post date:** [October 31, 2024, 6:58pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/7 "2024-10-31T18:58:30Z")

</div>

Ah, I see… that’s on me. I realize the post got a bit messy. The first code is what I’m currently using, while the second(the screen shot) is the one I plan to test out. The issue remains unclear though, because if it’s not double incrementing, then something else must be causing it.

---

<div class="post-metadata">

**Author:** ![lantram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lantram/32/977871_2.png) [@lantram](https://forums.unrealengine.com/u/lantram)\
**Post date:** [November 3, 2024, 5:03pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/8 "2024-11-03T17:03:29Z")

</div>

Where is TeleportToTeamSelection being called from?

---

<div class="post-metadata">

**Author:** ![lantram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lantram/32/977871_2.png) [@lantram](https://forums.unrealengine.com/u/lantram)\
**Post date:** [November 3, 2024, 5:21pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/9 "2024-11-03T17:21:13Z")

</div>

> [@Rak\_Bibi](#):
>
> ```auto
> set Team_Manage.TeleporterNum = 0
> 
> for (Player : GetPlayspace().GetPlayers()):
> TeleportToTeamSelection(Player)
> set Team_Manage.TeleporterNum += 1
> 
> ```

In any case, you’ve got some assumptions there that you should not be doing. You gotta remember Verse is failable. A. You gotta always assume that everything might fail. Because it can and will. B. GetPlayspace() is a scary function that you better have a reason for using it. And you better know what you are doing with it. Maybe you do, maybe you don’t. I don’t know. C. You have an assumed += which goes back to A. I would rethink this blurb of code if is important to your game and replace it with a better function.

---

<div class="post-metadata">

**Author:** ![Rak\_Bibi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rak\_Bibi](https://forums.unrealengine.com/u/Rak_Bibi)\
**Post date:** [November 4, 2024, 10:28am UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/10 "2024-11-04T10:28:16Z")

</div>

Thank for the response lantram

`TeleportToTeamSelection` is an array of teleporters that I defined at the head of the file.

I use `GetPlayspace().GetPlayers()` to get all the current players in order to teleport them to where i want, is it ok to use it like that ?

Regarding the `+=` operation, I switched to what Lama suggested to ensure I always find a valid teleporter.

I changed:

```auto
set Team_Manage.TeleporterNum += 1

```

to this:

```auto
set Team_Manage.TeleporterNum = Mod[Team_Manage.TeleporterNum + 1, TeamSelectionTeleportersArray.Length]

```

Is there anything else I should pay attention to?

---

<div class="post-metadata">

**Author:** ![lantram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lantram/32/977871_2.png) [@lantram](https://forums.unrealengine.com/u/lantram)\
**Post date:** [November 4, 2024, 6:57pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/11 "2024-11-04T18:57:20Z")

</div>

This is just me, so feel free to roast and/or ignore my advice.

#1. If you find yourself doing GetPlayspace().GetPlayers() in the middle of your game, then you already messed up

#2. That whole mod thing, yeah, super cool but … why?

#3. Don’t use hard coded indexes

#4. Assume everything will fail. Always. And write your code to handle those situations

#5. When you have something super important, make your code super paranoid in handling everything failing and responding appropriately

#6. Always remember that fort\_character is evil. It will bite you. Never forget it, and then only use it knowing that

#7. And, call me crazy but you should have a player manager and should be setting it up with that evil fort\_character like this:

GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)  
GetPlayspace().PlayerRemovedEvent().Subscribe(OnPlayerRemoved)

That way you know the players. And you do not need to ask

---

<div class="post-metadata">

**Author:** ![Rak\_Bibi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rak\_Bibi](https://forums.unrealengine.com/u/Rak_Bibi)\
**Post date:** [November 8, 2024, 2:37am UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/12 "2024-11-08T02:37:40Z")

</div>

Thank you so much for the tips man 🤩

Sorry for the delay i was on a few days off.

About #1 what should i do instead ? Create a list with all the players and update it ?  
About #2 so the `Team_Manage.TeleporterNum` won’t increment above the array length  
About #3 OK, just looked up what hard coded indexes are, and got it 👍🏼  
About #4 & #5 Got it.  
About #6 I will read more about it !  
About #7 Same question as #1

Now i hate the evil fort\_character 😠 😂

---

<div class="post-metadata">

**Author:** ![lantram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lantram/32/977871_2.png) [@lantram](https://forums.unrealengine.com/u/lantram)\
**Post date:** [November 13, 2024, 2:13pm UTC](https://forums.unrealengine.com/t/some-players-are-not-being-teleported-using-verse-teleport-device/2095782/13 "2024-11-13T14:13:52Z")

</div>

Make a player manager device. Put a map object in it. Put all your spawners in it (the device) as editables. (Make sure you add 1 more spawner than the maximum number of players.) Subscribe to player added, player removed, and player spawned events. When a player shows up (either by spawning in or the player added event), see if they are in the map and if they aren’t add them. When a player leaves (player removed event) find them in the map and remove them.

The map object is your “list” of players. Look them up using agent to get player, then use player as an index to get your “custom” player object that has all of the stuff you want to keep track of about the player. (You’ll need to make a unique class for that.)

There should be videos on YouTube about how to keep track of players (via custom player maps). Look up Warforge, Graeme Bull, and there are probably some others.

In regards to my comments about fort\_character, if/when you find yourself using `GetFortCharacter[]` (for a valid reason, of course) - just make sure you use `IsActive[]` on the result to make sure it is actually valid.
