function Ownership.WaitForPlayerInRange(q,k)if#Players:GetPlayers()==0 then Players.PlayerAdded:Wait()end local P repeat for L,b in pairs(Players:GetPlayers())do if b and(b.Character and b.Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"))then if(b.Character.HumanoidRootPart.Position-q.Model.PrimaryPart.Position).Magnitude<=k then P=b break end end end wait(.1)until P or#Players:GetPlayers()==0 if not P then q:WaitForPlayerInRange(k)else q:SetOwner(P)end end
--[[			
	@param 	Number 		Range			The radius for which we will search for players (characters).
--]]
function Ownership:WaitForPlayerInRange(Range)
	-- Check if there are actually players in game - if not, wait for a player to join
	if #Players:GetPlayers() == 0 then
		Players.PlayerAdded:Wait()
	end

	local Player
	repeat
		for _, player in pairs(Players:GetPlayers()) do
			if player and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
				if
					(player.Character.HumanoidRootPart.Position - self.Model.PrimaryPart.Position).Magnitude <= Range
				then
					Player = player
					break
				end
			end
		end
		wait(0.1)
	until Player or #Players:GetPlayers() == 0
	-- The loop waits until either a Player has been found or there are no more players left in the game.

	-- If no player was found, it means the other condition (no players in game) was triggered.
	if not Player then
		-- We (re-)call this method to make use of PlayerAdded:Wait() instead of a repeat-loop, for efficiency.
		self:WaitForPlayerInRange(Range)
	else
		self:SetOwner(Player)
	end
end
