I want to make it so, when the player is atleast 5 studs from another player, the other player will have a surfacegui pop up on his torso, and If they click (e) then another gui pops up but I am stuck on the magnitude part

function findPlayer()
	for i, v in pairs(game.Players:GetChildren()) do
		if (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - v.Character.HumanoidRootPart.Position).magnitude <= 5 then
			return v.Character
		end
	end	
end

while true do
	wait(0.05)
	if findPlayer() then
		
	end
end

1 comment

0

Try CFrame instead of Position.