How could this teleport the player instead of killing them?

Hello, I’ve made a simple handler for killing the player if they touch a kill part, however I would like to make it teleport them to the spawn instead. Any help or suggestions are appreciated.

function DescendantAdded(D)
	if not D:IsA("BasePart") then return end
	if D.Name == "Darkness" then

		D.Touched:Connect(function(Hit)
			if not Hit.Parent:FindFirstChild("Humanoid") then return end

			Hit.Parent.Humanoid.MaxHealth = 0
			Hit.Parent.Humanoid.Health = 0
		end)
	end
end

game.Workspace.DescendantAdded:Connect(DescendantAdded)

for _, v in pairs(game.Workspace:GetDescendants()) do
	DescendantAdded(v)
end
1 Like

Maybe instead of killing the player, it uses LoadCharacter instead?

Alright I might use this, however I was thinking of something like teleporting the players CFrame to the SpawnLocation instead but I don’t exactly know how to incorporate that.

Then just change the part of this code to teleporting them by changing the model’s CFrame to a SpawnLocation’s CFrame.

2 Likes

Oh okay so after looking at the script I found that I was trying to get the CFrame of the wrong thing now it works.