I have a script where when a player presses a button, they get teleported to their spawn:
local Plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
Plr.Team = game.Teams.Prisoner
Plr.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.Prisoner.Position + Vector3.new(0, 10, 0))
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)
I have a spawn location called 'Prisoner' and the team colour is set exactly to the prisoner team colour, with both 'Neutra'l and 'AllowTeamChangeOnTouch' set to false.
However, whenever a player dies, it doesn't respawn it back to their team's spawnlocation, but spawns them in the middle of the map.
How do I fix this problem?
Any help is appreciated.

7 comments
I typed in this code: Player.Prisoner = workspace[Player.Team.Name] (where Prisoner is the name of the SpawnLocation under workspace. Then Roblox outputs with this message: Unselected is not a valid member of Workspace. How do I fix this problem?
When I type in the CharacterAdded event, this message occurs: Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this. How do I fix this problem? Thank you
I find that odd, Player.Prisoner will fail, leave it as Player.RespawnLocation = workspace[Player.Team.Name]
It is trying to find a Part in workspace that matches the name of their Team, ensure the SpawnLocation is called Prisoner, as well as team
The reason why I couldn’t is because they had no team, make sure the player is a Prisoner before running that line
With the modified CharacterAdded code, try it with MoveTo
Both codes shows no errors in the Roblox output, but it still spawns my player in the middle of the map.