RespawnLocation

Hey so I’m having an issue with a player’s RespawnLocation. I have two spawn locations, Location1 and Location2. Both are enabled but only one is neutral (Location2). I wanted to have a player click a button to change their spawn location.

game.Players.LocalPlayer.RespawnLocation = workspace.Location1

When I test the game, the player’s Respawn location property changes but when I reset I do not respawn at the expected location.image

3 Likes

you could use something like CharacterAdded event (when the player is added to the game)

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character.HumanoidRootPart.Position = player.RespawnLocation
    end)
end)

the CharacterAdded event will fire again when the player resets.

1 Like

According to the DevHub, the spawn has to be set to Neutral or correspond with the player’s TeamColor for this property to apply.

4 Likes

This creates another issue. In the script when the button is pressed I have it now so it disables neutral on Location2 and enables it on Location1. Upon resetting my character will still spawn at Location2, despite it not being neutral or the same TeamColor.
Location1:
image
Location2:
image
Player:
image

Are you changing the Neutral property on the client by any chance? If not, could I see your code to test?

Local Script

function onButtonActivated()
        local button = script.Parent.Play
        workspace.DefaultSpawn.Neutral = false
		workspace.Location1.Neutral = true

button.Activated:Connect(onButtonActivated)

No errors in the output either.
Also renamed Location2 to DefaultSpawn.
Forgot to mention, it’s a GUI button.

I suggest you doing a something like this: Having normal parts instead of SpawnLocation and then let the player choose spawn. Put the spawn into a table and use move to function to move their character to the spawn

What do you mean by “a table”?
Do you mean I make a part and put a spawn inside it?

The server will not recognize any changes made on the client when determining the player’s spawn location. You’ll need to set up a RemoteEvent to convey this information to the server; however, this will also affect any other players, so you might have to resort to a different method.

2 Likes

No, when the player choose the spawn which should be a part not a spwn location. Put that part into a table so you can access it easier and then use move to function to teleport player to that spawn cuz it is a part so you have to teleport them manually

If it’s going to be that complicated I’ll just use teams instead.

It’s not complicated it’s quite beginner stuff, I would say teams will be far more complicated but it’s up to you just trying to help

I mean it’s how you explained it that was confusing.

Oh sorry, I’ll send a sample of a script instead maybe easier then

1 Like

Acually you don’t need the table thing here is the script, but you need a local script also that fire the remote event when player has chosed the team from client

2 Likes