function Checkpoint.new(b,Q)assert(b,"\084\114\121\105\110\103 \116\111 \115\101\116 \112\097\114\116\108\101\115\115 \099\104\101\099\107\112\111\105\110\116")local O={CollisionBody=b,Manager=Q}setmetatable(O,Checkpoint)O.PlayersTouched={}O.CollisionBody.Touched:connect(function(b)if b and b.Parent then local Q=game.Players:GetPlayerFromCharacter(b.Parent)if Q then O.Manager:PlayerCrossedCheckpoint(Q,O)end end end)O.CollisionConnection=nil return O end function Checkpoint.Reset(b)b.PlayersTouched={}end function Checkpoint.SetPlayerPassed(O,b,Q)local o=O.PlayersTouched[b]==Q O.PlayersTouched[b]=Q return o end function Checkpoint.PlayerLapPassed(Q,b)return Q.PlayersTouched[b]end
-- ================================================================================
-- PUBLIC FUNCTIONS
-- ================================================================================
function Checkpoint.new(collisionBody, manager)
	assert(collisionBody, "Trying to set partless checkpoint")

	local newCheckpoint = { CollisionBody = collisionBody, Manager = manager }
	setmetatable(newCheckpoint, Checkpoint)

	newCheckpoint.PlayersTouched = {}

	newCheckpoint.CollisionBody.Touched:connect(function(otherPart)
		if otherPart and otherPart.Parent then
			local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
			if player then
				newCheckpoint.Manager:PlayerCrossedCheckpoint(player, newCheckpoint)
			end
		end
	end)

	newCheckpoint.CollisionConnection = nil

	return newCheckpoint
end -- Checkpoint.new()

function Checkpoint:Reset()
	self.PlayersTouched = {}
end -- Checkpoint:Reset()

function Checkpoint:SetPlayerPassed(player, lapNumber)
	local alreadyPassed = (self.PlayersTouched[player] == lapNumber)
	self.PlayersTouched[player] = lapNumber
	return alreadyPassed
end -- Checkpoint:SetPlayerPassed()

function Checkpoint:PlayerLapPassed(player)
	return self.PlayersTouched[player]
end -- Checkpoint:PlayerLapPassed()
