Checkpoint script made by RealAlphaMango

I’m working on a checkpoint script that works sometimes but when it doesn’t I spawn I suffocate into the checkpoint. I’ve tried using MoveTo, PrimaryPart, and playing with Vector3 and CFrame but I couldn’t find anything that works. Sometimes when i’ve tried doing different things it’s ended up making my legs act as if cancollide was false or making my body go invisible and kind of fling around the map. The video by RealAlphaMango is also this link.

local folder = workspace.Checkpoints
local checkpoints = folder:GetChildren()

local PlrCheckpoints = {}

game.Players.PlayerAdded:Connect(function(plr)
	
	PlrCheckpoints[plr] = 1
	
	plr.CharacterAdded:Connect(function()
		task.wait()
		
		local PlrCheckpoint = PlrCheckpoints[plr]
		local checkpoint = folder:FindFirstChild(PlrCheckpoint)
		
		if checkpoint then
			local HRP = plr.Character.HumanoidRootPart
			HRP.CFrame = checkpoint.CFrame
		end
	end)
end)

for i, v in pairs(checkpoints) do
	local checkpointnum = tonumber(v.Name)
	v.Touched:Connect(function(part)
		
		local char = part.Parent
		local player = game.Players:GetPlayerFromCharacter(char)
		if player then
			
			local PlrCheckpoint = PlrCheckpoints[player]
			if PlrCheckpoint < checkpointnum then
				PlrCheckpoints[player] = checkpointnum
			end
		end
	end)
end


if checkpoint then
    local HRP = plr.Character.HumanoidRootPart
    HRP.CFrame = CFrame.new(checkpoint.Position) * CFrame.new(0,5,0)
end

This should work…

1 Like

Thank you so much, it worked! I didn’t know you could work with CFrame.new like that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.