How to disable/enable spawn locations for specific players

I am making an obby game and want to have checkpoints but don’t want to do it with teams so what I was going to do was make a touched event so when the player touches the spawn it fires a bindable event and the server enables that spawn location and disables the others for that specific player. I can do everything else I just don’t know how I can disable/enable spawn locations for a specific player.

1 Like

I think what you can do instead of enabling and disabling, is to use the Player.RespawnLocation property, giving it the current spawnlocation that they should respawn at (Thank you @uhSkittle for telling me about that, never knew about that property before)

Though a better way if you’re just having a number determine your current checkpoint, have the checkpoints in a separate folder and an IntValue in a leaderstats (or the player if you don’t want it to be displayed).

Each checkpoint should be named a number that corresponds to its section (1 for checkpoint 1, 2 for checkpoint 2, etc.). When you touch a part, it increments the intvalue by 1 if the player has never met that checkpoint before (Checkpoint number == current + 1) and sets the RespawnLocation property to be that checkpoint

Hopefully my explanation is understandable, I can explain more clearly if need be

7 Likes

Instead of creating an ObjectValue, you can also use Player.RespawnLocation

2 Likes

That’s probably what I will end up using however lets say after a certain period of time I wanted players to spawn at the default spawn location, which is multiple spawn locations in my situation so I can’t just set it using player.SpawnLocation. How would I do that.

1 Like

What do you mean exactly by default spawn location? When the player first joins the game?

1 Like

Yes I have a lobby that players spawn into and when a game starts an obby is spawned and in that obby I will put checkpoints in. When the round is over I want players to spawn back into the default roblox checkpoints.

1 Like

You can try using team spawnlocations

1 Like

In that case you can set all players respawnLocation to nil and remove/disable all spawnlocations in that obby, since then roblox will just use its spawnlocation logic to move you to a spawn since I don’t think you have a Non-playing/playing team system, if you do, change the team of the player to the spawnlocation’s team

2 Likes

If you want you can disable each team’s ‘AutoAssignable’ property and then enable each spawn location’s ‘AllowTeamChangeOnTouch’ property.

https://developer.roblox.com/en-us/api-reference/property/Team/AutoAssignable
https://developer.roblox.com/en-us/api-reference/property/SpawnLocation/AllowTeamChangeOnTouch

This will both prevent teams from having players assigned to them and allow players to change teams upon touching a spawn location that belongs to a particular team.

1 Like