Player is not respawning at set respawn point

local checkpointFolder = workspace:WaitForChild("Fake Checkpoints")
local checkpoint = checkpointFolder:WaitForChild("Checkpoint1")
_G.runbefore = false
checkpoint.Touched:Connect(function(hit)
	if _G.runbefore == false then
		local partParent = hit.Parent
		local player = Players.LocalPlayer
		local humanoid = partParent:FindFirstChild("Humanoid")
		local realSpawnLocation = workspace:WaitForChild("RealSpawnLocation")
		if humanoid then
			realSpawnLocation.Position = Vector3.new(100,100,100)
			realSpawnLocation.Anchored = true
			player.RespawnLocation = realSpawnLocation
			_G.runbefore = true
		end
	end
end)

(Inside of a local script)

1 Like

Try from a script. Client may not be able to set its own spawn location by design.

2 Likes

I just tried that but sadly it didn’t help, it had the same result as before.

What does the new script look like?

Example from the docs:

local Players = game:GetService("Players")

local function addSpawn(spawnLocation)
	-- listen for the spawn being touched
	spawnLocation.Touched:Connect(function(hit)
		local character = hit:FindFirstAncestorOfClass("Model")
		if character then
			local player = Players:GetPlayerFromCharacter(character)
			if player and player.RespawnLocation ~= spawnLocation then
				local humanoid = character:FindFirstChildOfClass("Humanoid")
				-- make sure the character isn't dead
				if humanoid and humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
					print("spawn set")
					player.RespawnLocation = spawnLocation
				end
			end
		end
	end)
end

local firstSpawn

-- look through the workspace for spawns
for _, descendant in pairs(workspace:GetDescendants()) do
	if descendant:IsA("SpawnLocation") then
		if descendant.Name == "FirstSpawn" then
			firstSpawn = descendant
		end
		addSpawn(descendant)
	end
end

local function playerAdded(player)
	player.RespawnLocation = firstSpawn
end

-- listen for new players
Players.PlayerAdded:Connect(playerAdded)

-- go through existing players
for _, player in pairs(Players:GetPlayers()) do
	playerAdded(player)
end

Looks similar to what you are trying to do, though they are using touch event on the spawnlocation itself.