function Checkpoint.new(Y,u)assert(Y,"\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 d={CollisionBody=Y;Manager=u}setmetatable(d,Checkpoint)d.PlayersTouched={}d.CollisionBody.Touched:connect(function(Y)if Y and Y.Parent then local u=game.Players:GetPlayerFromCharacter(Y.Parent)if u then d.Manager:PlayerCrossedCheckpoint(u,d)end end end)d.CollisionConnection=nil return d end function Checkpoint.Reset(Y)Y.PlayersTouched={}end function Checkpoint.SetPlayerPassed(d,Y,u)local R=d.PlayersTouched[Y]==u d.PlayersTouched[Y]=u return R end function Checkpoint.PlayerLapPassed(u,Y)return u.PlayersTouched[Y]end

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()