function Ownership.WaitForPlayerInRange(Q,e)if#Players:GetPlayers()==0 then Players.PlayerAdded:Wait()end local o repeat for H,Z in pairs(Players:GetPlayers())do if Z and(Z.Character and Z.Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"))then if(Z.Character.HumanoidRootPart.Position-Q.Model.PrimaryPart.Position).Magnitude<=e then o=Z break end end end wait(.1)until o or#Players:GetPlayers()==0 if not o then Q:WaitForPlayerInRange(e)else Q:SetOwner(o)end end

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
