Spawning on roof of building

Hello! My script that makes me respawn on checkpoint keeps making me spawn on top of the building when you join the game.

Script: local spawn = script.Parent
spawn.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local checkpointData = game.ServerStorage:FindFirstChild(“CheckpointData”)
if not checkpointData then
checkpointData = Instance.new(“Model”, game.ServerStorage)
checkpointData.Name = “CheckpointData”
end

	local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
	if not checkpoint then
		checkpoint = Instance.new("ObjectValue", checkpointData)
		checkpoint.Name = tostring(player.userId)

		player.CharacterAdded:connect(function(character)
			wait()
			character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
		end)
	end

	checkpoint.Value = spawn
end

end)

Are you sure that the checkpoint isn’t placed on the top of the building?

If its possible maybe lower the spawn part or increase the height of the building.
if not maybe use cframe to make the player spawn at a lower point.
Also if players arent ever going to be on the roof you can turn of cancollide on it so you just go right through it

I’m sure as it’s placed inside.

I can though it will still spawn player on top so the player will see themselfs fall through.

character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0) -- Player will be teleported 4 studs higher?

Maybe try this:

character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame

What does this do? Does it work?

I just tried it, it does not work.

Maybe try:

character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 1, 0)

That works thank you people super helpful!

No problem, sir! I hope I helped.

Select the answer as a solution so others can see it!

1 Like