Clean way to implement custom respawn logic that respects "Play Here" in Studio

As a Roblox developer, it is currently too hard to implement custom respawn logic that doesn’t override the player’s position when they start a local test through Play Here.

As far as I can tell, the best way to implement this behavior currently is to measure the player’s distance from the default spawn position on respawn, and only override their position if they’re far enough away.

If Roblox is able to address this issue, it would improve my development experience because I could implement custom respawn logic that respects Play Here without unreliable workarounds.

5 Likes

How would Roblox even do this? An additional parameter to PlayerAdded or RunService that tells you if you “played here”?

I was thinking of some additional method/property for RunService, but feature requests are supposed to focus on the problem rather than proposed solutions. RunService already offers a method to determine if the game was started with Run in Studio.

Maybe something like RunService:IsPlayHere() and you can skip your respawn logic if it’s true.

2 Likes

Interesting, I’ve never personally been bugged about not respawning where my studio cam or my “play here place” was positioned.

I guess it would make sense though

By exposing the API the CoreScripts use. I somewhat doubt it runs in C++.

Also, this feature request is quite an interesting one. I’ve not had this issue, but at the same time, it feels necessary to have.

3 Likes

Something like this would be nice to have:

function RunService:GetPlayPosition(): Vector3?

I’ve experienced this issue before in one of my old games with custom respawn logic. It would be nice if I could grab this value so I can change it to fit my debugging needs.

1 Like

I suggested Roblox should do respawn logic through a callback. However, idk how you’d check if the game was started in Play Here mode

function Player.RespawningCharacter(cf: CFrame)
  -- return the same or new position
  -- for example, this places the player 5 studs
  -- above where the server wants to put them

  return cf + Vector3.new(0, 5, 0)
end

This callback would only control the spawn position of the Player, maybe having a SpawnLocation in the callback when applicable is a good idea as well, ie: (CFrame, SpawnLocation) -> (CFrame|SpawnLocation)??