Players.PlayerInputBegan:Connect(function(Z,H)if H.KeyCode==Enum.KeyCode.E then local H=nil local S=math.huge for w,e in pairs(gameState.enemies)do local N=(e.Position-Z.Character.HumanoidRootPart.Position).Magnitude if N<S then H=e S=N end end if H~=nil then H:TakeDamage(10)end end end)
-- Create the player input event handler
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)
