Players.PlayerInputBegan:Connect(function(b,P)if P.KeyCode==Enum.KeyCode.E then local P=nil local v=math.huge for r,x in pairs(gameState.enemies)do local d=(x.Position-b.Character.HumanoidRootPart.Position).Magnitude if d<v then P=x v=d end end if P~=nil then P:TakeDamage(10)end end end)

Players.PlayerInputBegan:Connect(function(player, input)
	-- Check if the player is pressing the fire button
	if input.KeyCode == Enum.KeyCode.E then
		-- Shoot at the nearest enemy
		local nearestEnemy = nil
		local nearestDistance = math.huge
		for _, enemy in pairs(gameState.enemies) do
			local distance = (enemy.Position - player.Character.HumanoidRootPart.Position).Magnitude
			if distance < nearestDistance then
				nearestEnemy = enemy
				nearestDistance = distance
			end
		end

		if nearestEnemy ~= nil then
			-- Shoot at the enemy
			nearestEnemy:TakeDamage(10)
		end
	end
end)
