Player Spawnpoints not working

Hello, I recently came to realize that player.RespawnLocation doesn’t work.
I know there are alternatives like teams, but what is the best and least complicated way of setting the player’s spawn.

I need to set the player’s spawn when the player gets added , but I don’t want to use teams, and it wouldn’t make sense since you aren’t supposed to have teams in the game and everyone should have their own spawnpoint without teams.

3 Likes


Screenshot taken from the documentation.

Is the SpawnLocation’s teamcolor set to the same team as the player?
Is the SpawnLocation’s Neutral property set to true?

None of my checkpoints have neutral set to true.
and there aren’t any teams in the game, as I said is there another way than teams , since only one player needs the spawn and also for my personal prefrence

What is the script and where’s the issue ?

There is no example script since there are no errors, I am just asking how to set a player’s checkpoint

RespawnLocation must meet the following for it to work :
1 . the SpawnLocation must be a descendant of workspace
2 . SpawnLocation.TeamColor is set to Player.TeamColor Or SpawnLocation.Neutral is set to true
https://developer.roblox.com/en-us/api-reference/property/Player/RespawnLocation

1 Like

but if its true , won’t everyone spawn on it then?

you can actually set an attribute for the SpawnLocation as the player’s name and check for it later

if SpawnLocation:GetAttribute("Name") == plr.Name then
plr.RespawnLocation = SpawnLocation
end

Oh umm, here’s the scripts (In ServerScriptService):

local DS = game:GetService("DataStoreService"):GetDataStore("Stage Save")

local function OnCharacterAdded(char)
	game:GetService("RunService").Stepped:Wait()
	local plr = game.Players:GetPlayerFromCharacter(char)
	char:WaitForChild("HumanoidRootPart").CFrame = workspace.Checkpoints[tostring(plr.TeleportedStage.Value)].CFrame + Vector3.new(0,3.25,0)
end

function OnPlayerAdded(plr)
	
	plr.CharacterAdded:Connect(OnCharacterAdded)
	
	local stats = Instance.new("Folder")
    stats.Name = "leaderstats"
	stats.Parent = plr
	
	local stage = Instance.new("IntValue")
    stage.Name = "Stage"
	stage.Parent = stats
	
	local TeleStage = Instance.new("IntValue")
    TeleStage.Name = "TeleportedStage"
	TeleStage.Parent = plr
	
	local key = "id_" .. plr.userId
	
	local data = DS:GetAsync(key)
	
	if data then
		stage.Value = data
		TeleStage.Value = stage.Value
	else
		DS:GetAsync(key, stage)
	end
	
end

game.Players.PlayerAdded:Connect(OnPlayerAdded)

function OnPlayerRemoved(plr)
	local key = "id_" .. plr.userId
	local data = plr.leaderstats.Stage.Value
	DS:SetAsync(key, data)
end

game.Players.PlayerRemoving:Connect(OnPlayerRemoved)
local RS = game:GetService("ReplicatedStorage")

repeat wait() until script.Main ~= nil

local main = require(script.Main)

function recived(plr, direction)
	if direction == "up" then
		main.up(plr, direction)
	elseif direction == "down" then
		main.down(plr, direction)
	elseif plr.Stages > main.TOTAL_STAGES_IN_GAME then
		print("Player is in an older version of the game!")
	end
end

RS.StageTransfer.OnServerEvent:Connect(recived)
local trasferHandler = {}

local TOTAL_STAGES_IN_GAME = 0 -- Pick your number !

for _, stage in pairs(workspace.Checkpoints:GetChildren()) do
	if tonumber(stage.Name) > TOTAL_STAGES_IN_GAME then
		TOTAL_STAGES_IN_GAME = tonumber(stage.Name)
	end
end

function trasferHandler.up(plr, direction)
	local tpStage = plr.TeleportedStage
	if tpStage.Value < plr.leaderstats.Stage.Value then
		tpStage.Value += 1
		plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[plr.TeleportedStage.Value].CFrame + Vector3.new(0,3.25,0)
	elseif tpStage.Value == plr.leaderstats.Stage.Value then
		tpStage.Value = 0
		plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints["0"].CFrame + Vector3.new(0,3.25,0)
	end
end


function trasferHandler.down(plr, direction)
	local tpStage = plr.TeleportedStage
	if tpStage.Value > 0 then
		tpStage.Value -= 1
		plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[tpStage.Value].CFrame + Vector3.new(0,3.25,0)
	elseif tpStage.Value == 0 then
		tpStage.Value = plr.leaderstats.Stage.Value
		plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[plr.leaderstats.Stage.Value].CFrame + Vector3.new(0,3.25,0)
	end
end

return trasferHandler


for _, v in pairs(workspace.Checkpoints:GetChildren()) do
	v.Touched:Connect(function(hit)
		if v ~= nil then
			if v.Parent == workspace.Checkpoints then
				local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
				if player then
					if player.leaderstats.Stage.Value == tonumber(v.Name) - 1 then
						player.leaderstats.Stage.Value += 1
						player.TeleportedStage.Value = player.leaderstats.Stage.Value
					end
				end
			end
		end
	end)
end

Those are not my scripts, though.

The Main ModuleScript is inside of Stage Transfer Handler.

But anyways, what do you want to do with it ?
A difficulty chart obby.

The game when it has obbies with different difficulties.

Others

Other then the Obby Difficulty Chart obby with a respawn time as of the topic said.

Make sure to do this:

bandicam 2022-08-21 15-57-59-334

Into:

bandicam 2022-08-21 15-58-43-176

I think you might find this video helpful.

Note: this is making sure that only one player can spawn at a certain spawnpoint. Also, this does use player.RespawnLocation but you might still want to try it.

Hope this helps! :slightly_smiling_face:

I feel dumb , anyways setting the respawn location does work

1 Like